- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
First out
Admin
TMTOWTDI
Not spam, Askimet
Admin
Frist! PS: Not spam...
Admin
But this version supports platforms where wc doesn't have -l.
Admin
Oh great, I can hear the stampede of linux geeks waddling to their keyboards now...
Admin
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!!!
Admin
The final line of this comment was supposed to be my whole comment, but apparently it looks like spam to some algorithm:
Man!
Admin
It's okay dear. Here, come sit down and play some minesweeper.
Admin
"... 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.
Admin
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.
Admin
Never have I wanted to 'upvote' a reply more than I do now...
Admin
Counting lines is easy: Minus, Slash and Backslash - 1 Plus, Equals, Less Than, T - 2 Asterisk , H, K, F - 3 Octothorpe - Many.
Admin
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....
Admin
TRWTF is um perl?
Admin
Right on queue: the circle-jerk begins.
Admin
So what you are saying is... there is no WTF, except for the OP not understanding the requirements of the script?
Admin
Is yours just a one-man party?
Admin
Admin
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.
Admin
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.
Admin
Of course! What, is there something else you're supposed to do while at work?
Admin
I don't work with toilets on the command line so I count lines with awk:
Admin
There's not much else to do where I live.
Admin
Admin
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
Seriously, what is wrong with people?
Admin
Admin
You have a job?!?! Someone pays you?!?!
Admin
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;}'
Admin
If by job you mean laid-off and by pay you mean UI, then yes, I have a paying job...
Admin
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.
Admin
It is at C:\WINDOWS\SYSTEM\drv\etc\hosts
Admin
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.
Admin
YHBT YHL HAND
I'll let that sink in.
Admin
%WINDOWS_DIRECTORY%\SYSTEM32\drivers\etc\hosts
YMMV on x64 systems.
Admin
So just in case you aren't using GNU tools.
Admin
CAN YOU SEND ME THOSE CODEZ TO MY AOL? I WANT TO HAK MY EX'S EMAL.
-SCRIPTKIDDIE29923
Admin
So... apparently this should return more than just the line count:
Admin
Still could've done that much better:
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).
Admin
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.
Admin
For maximum fun, the 32-bit compatibility libraries are stored in the WoW64 folder...
Figure that one out...
Admin
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?
Admin
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!
Admin
Admin
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.
Admin
Mr. Kettleblack, there is a call for you, a Mr. Pot is on the line.
Admin
C-Octomom's "jokes" are a crime against comedy.
Admin
Admin
In C:\Windows\System32\Drivers of course ;)
Admin
Well, WoW64 does make a twisted kind of sense if you write it out - Windows on Windows64.
Admin
This isn't a WTF, it's job security!
DaveE