| « Prev | Page 1 | Page 2 | Page 3 | Page 4 | Next » |
|
First out
|
|
TMTOWTDI
Not spam, Askimet |
|
Frist!
PS: Not spam... |
|
But this version supports platforms where wc doesn't have -l.
|
|
Oh great, I can hear the stampede of linux geeks waddling to their keyboards now...
|
Re: How Not to Count Lines
2011-06-29 10:43
•
by
Windozer
(unregistered)
|
What's a wc? What's a perl? Why do all of these backslashes go the wrong way? What's going on? HALP ME, I DON'T UNDERSTAND!!! |
|
The final line of this comment was supposed to be my whole comment, but apparently it looks like spam to some algorithm:
Man! |
Re: How Not to Count Lines
2011-06-29 10:45
•
by
justsomedude
(unregistered)
|
It's okay dear. Here, come sit down and play some minesweeper. |
|
"... the author thought to use the wc command but not the -l option."
It's for flexibility. If you want to change it to report characters instead, you only need to change the parameters to cut, instead of having to replace wc -l with wc -c. |
|
It's obvious, can't you see? wc -l puts all those spaces on the front of the output, and you need all that gubbins to get rid of them!
It's not like this could do the job, is it? wc -l < /var/run/netstat_r.lst | tr -d ' ' or even wc -l < /var/run/netstat_r.lst | sed "s/ //g" And no, I'm not a Linux geek. I'm a FreeBSD geek. |
Re: How Not to Count Lines
2011-06-29 10:49
•
by
simple
(unregistered)
|
Never have I wanted to 'upvote' a reply more than I do now... |
|
Counting lines is easy:
Minus, Slash and Backslash - 1 Plus, Equals, Less Than, T - 2 Asterisk , H, K, F - 3 Octothorpe - Many. |
|
This smacks of someone doing something I WISH I had done to someone.
I was asked in a chatroom at work in all seriousness: "Where is the /etc/hosts file??" I wish my response had been as convoluted as that approach above.... |
TRWTF is um perl? |
Right on queue: the circle-jerk begins. |
So what you are saying is... there is no WTF, except for the OP not understanding the requirements of the script? |
Re: How Not to Count Lines
2011-06-29 10:58
•
by
Hortical
(unregistered)
|
Is yours just a one-man party? |
Actually TRWTF was my knee-jerk reaction trying to state a WTF, by forgetting that the input to perl is the output of wc. I've since updated my comment, but sadly not before you quoted me. :) |
|
Couldn't you just determine the average number of characters per line and then divide the file size by this?
No I have realised this would only work if your characters were always one byte. |
Re: How Not to Count Lines
2011-06-29 11:00
•
by
jarfil
(unregistered)
|
Don't know about BSD, but GNU's wc puts no spaces with -l. Also, it takes an input file as a parameter, so no need for pipes: /usr/bin/wc -l /var/run/netstat_r.lst Now, all this "could" be not such a WTF if /usr/bin/wc was some kind of redirect like from busybox or the likes, that wouldn't support the -l option... although whether it would be possible to run perl in such case, kind of baffles me. |
Of course! What, is there something else you're supposed to do while at work? |
Re: How Not to Count Lines
2011-06-29 11:01
•
by
cihv
(unregistered)
|
|
I don't work with toilets on the command line so I count lines with awk:
awk '{lines++}END{print lines}' <filename>
|
Re: How Not to Count Lines
2011-06-29 11:03
•
by
C-Octothorpe
(unregistered)
|
There's not much else to do where I live. |
|
|
|
I don't see why he couldn't have just read the manual page for wc to find out what options it supported. It's as easy as typing
echo | gunzip -c $(find /usr/share/man -name 'wc\.*' | head -1 |awk '/wc/ { print $1}' | tail -1 ) | sed '' | /usr/bin/groff -mtty-char -Tutf8 -mandoc | cat -u | pager -s
Seriously, what is wrong with people? |
Re: How Not to Count Lines
2011-06-29 11:07
•
by
Pr0gramm3r
(unregistered)
|
Same shit different pile. |
Re: How Not to Count Lines
2011-06-29 11:08
•
by
Hortical
(unregistered)
|
You have a job?!?! Someone pays you?!?! |
Too right! The correct approach is obviously: /bin/cat /var/run/netstat_r.lst | /usr/bin/wc | /usr/bin/cut -b -8 | awk '{print $1;}' |
If by job you mean laid-off and by pay you mean UI, then yes, I have a paying job... |
Re: How Not to Count Lines
2011-06-29 11:12
•
by
Hortical
(unregistered)
|
So your life consists of jerking off in an internet cafe while talking to my many sockpuppets in comments threads on TDWTF. I'll let that sink in. |
Re: How Not to Count Lines
2011-06-29 11:13
•
by
PleegWat
(unregistered)
|
|
It is at C:\WINDOWS\SYSTEM\drv\etc\hosts
|
Re: How Not to Count Lines
2011-06-29 11:15
•
by
Jorrit
(unregistered)
|
|
Uhm, there are no formatting spaces when you do:
wc -l < FILENAME But I suppose it's always a good idea to remove them. Just in case. |
YHBT YHL HAND I'll let that sink in. |
Re: How Not to Count Lines
2011-06-29 11:17
•
by
Steve The Cynic
|
Not since Monkey Boy put the stake in the heart of Windows Me it's not. %WINDOWS_DIRECTORY%\SYSTEM32\drivers\etc\hosts YMMV on x64 systems. |
Re: How Not to Count Lines
2011-06-29 11:19
•
by
Steve The Cynic
|
On FreeBSD, wc -l displays spaces in front of the number, and if you give it filename args, it displays the name(s) after the numbers. So just in case you aren't using GNU tools. |
|
CAN YOU SEND ME THOSE CODEZ TO MY AOL? I WANT TO HAK MY EX'S EMAL.
-SCRIPTKIDDIE29923 |
|
So... apparently this should return more than just the line count:
|
Re: How Not to Count Lines
2011-06-29 11:29
•
by
David
(unregistered)
|
|
Still could've done that much better:
/bin/sed '/^\W*$/d' /var/run/netstat_r.lst | wc -l Could probably write an awk script that wouldn't need the pipe, but this is quite a bit more readable (if you're going to use regex's anyways). |
Re: How Not to Count Lines
2011-06-29 11:29
•
by
Hortical
(unregistered)
|
Hmmm... You admit to being an expendable loser (laid-off) with a narrow scope of expertise (doesn't understand unix) and I'm supposed to feel like the joke's on me? If it keeps you from killing yourself and entertaining us all day, I guess I'm fine with that. |
Re: How Not to Count Lines
2011-06-29 11:30
•
by
random_garbage
|
Actually, IIRC, for historical reasons, Win64 still keeps all the relevant 64-bit libraries, etc. in the System32 folder. For maximum fun, the 32-bit compatibility libraries are stored in the WoW64 folder... Figure that one out... |
Re: How Not to Count Lines
2011-06-29 11:34
•
by
tk421
(unregistered)
|
Your terrible life is a troll? Or your pretending to have a terrible life is a troll? Or the fact that he's trolling you is a troll? |
Well, the joke *is* on you because if you're too up-tight to recognize an obvious joke, then I feel really bad for you... Don't let me get in the way: nerd on brother! |
Hehe |
Re: How Not to Count Lines
2011-06-29 11:46
•
by
EvilSpudBoy
(unregistered)
|
|
You could have told him, "I'll send it to you." And then send, via interoffice, a manila folder labeled /etc/hosts containing a typewritten list of host names.
|
Re: How Not to Count Lines
2011-06-29 11:46
•
by
trtrwtf
(unregistered)
|
Mr. Kettleblack, there is a call for you, a Mr. Pot is on the line. |
|
C-Octomom's "jokes" are a crime against comedy.
|
Re: How Not to Count Lines
2011-06-29 11:50
•
by
trtrwtf
(unregistered)
|
Not everybody can be a dashing, sexy wordsmith like yours truly. |
Re: How Not to Count Lines
2011-06-29 11:57
•
by
SG_01
(unregistered)
|
In C:\Windows\System32\Drivers of course ;) |
Re: How Not to Count Lines
2011-06-29 11:58
•
by
Too Lazy To Sign In
(unregistered)
|
|
Well, WoW64 does make a twisted kind of sense if you write it out - Windows on Windows64.
|
|
This isn't a WTF, it's job security!
DaveE |
| « Prev | Page 1 | Page 2 | Page 3 | Page 4 | Next » |