- 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
No he has the array in scalar context.
Admin
Oh man, the irony... Just yesterday my coworker and I wrote a bash script to count the number of lines in our project. Apparently we could have done it much easier. CURSE YOU, MARK BOWYTZ FOR NOT DOING THIS YESTERDAY!! fist shake
(oh, and just for reference: what we did was find all the files in the directories, grep for files that end in .java, .cpp, .h[...], grep each of those files, counting the numbers of newlines in each, and then adding that to a global counter. Interestingly enough, the counts from wc and our bash script are two lines off - plus our bash script runs maybe only twice as slow? Which only takes about three seconds for ~850,000 lines of code(which of course doesn't take out comments at all, plus there's a lot of code from libraries that we've hacked up so that linecount is actually much higher than the "real" line count))
Admin
Am I'm not overweight, I'm "husky", at least that's what my mom says.
Admin
sigh You .Net programmers get all the chicks, don't you?
Admin
Oh science! Does that make it... a Perl strawman?
Admin
it was two awk words
Admin
when you say that it was only twice as slow.. were you including the time to develop it too? Way too many people on this site seem to think that the only performance which matters occurs at runtime.
Admin
when you say that it was only twice as slow.. were you including the time to develop it too? Way too many people on this site seem to think that the only performance which matters occurs at runtime.
Admin
Admin
Admin
Neither do I..
gawk 'END { print NF }' < filename
gawk being available on all non-windows platforms I support..
Admin
unzip, strip, touch, finger, grep, mount, fsck, more, yes, fsck, umount, sleep
Admin
Amateurs, just open /var/run/netstat_r.lst in notepad and count the none blank lines manually, you get paid the same at the end of the day.
Admin
Admin
Just like Unix, we can build our own joke.
Admin
That sounds more like Windows users...
and my quote disappeared and I CBA to go get it again. oh well.
Admin
Should have used awk then
Admin
Admin
Even douche bags are entitled to off-days.
Don't feed the troll! Didn't you read the sign on the cage?
Admin
I could name a few tools here - and 9/10ths of them are registered... I've learned my tools!!
Admin
If it doesn't hav a WC then it might do with a portable one...
Admin
Admin
You can learn a tool, but you can't learn him much.
Admin
Admin
grep -c . file
is all you need for non-blank lines. the "." is a regexp wildcard, and matches any line with at least one character.
Admin
Admin
The basic problem is that people are scared of Unix, and its lookalikes that for some obscure reason you are not allowed to call Unix. Solaris, FreeBSD, Linux, AIX, Ultrix, Irix: if it has 'ls', it's Unix. Well, if it has 'ls' and isn't BeOS, that is.
Anyway, what's known as 'Cargo Cult Programming', applies to Unix as well. People use 'ls -la', always, even if they'd want a different output. Because someone once showed them how to use 'ls -la', and therefore this mantra is repeated for all eternity. One does not question the mantra.
Similarly, people do not read man pages. Man pages are like the Holy Book before those pesky laymen insisted that they should be allowed to read it as well. One does not consult the Holy Book, or the man pages, for fear that a lightning bolt would incinerate them on the spot.
It applies to JavaDocs (and, presumably, the equivalents in other programming environments such as .NET) as well. The times I've seen convoluted code because the author didn't read the docs...
Also, people try to solve a problem as far as they can, and then ask the Guru for the rest of the solution. In such cases, I like to take a step back, because more often than not, they've worked out some complex way to do something that is standard functionality that they didn't know about, or which has a much simpler solution.
Now my colleagues have a rather different idea of what 'simple' means than I do, but that's because they're all mad.
Admin
Nah; the real WTF, and a very common one, is at the very beginning: the use of cat, which does nothing but waste cpu time. I see that done all the time, and I always wonder what's going on in people's minds. Why would someone even waste their own time typing the cat command when the next command would accept the file name as an arg? Is there some problem that I don't know about when a command line finishes too quickly?
Admin
Um, the reason isn't obscure at all; it's called "trademark law". The name "unix" is a registered trademark (at least in the US). You can legally implement an act-alike OS, by following the POSIX standard, but you can't legally call your OS "unix" without being sued by whichever corporation owns the trademark this month. Yes, you could get a license, but then you'd have to pay royalties for every copy you sold (or handed out free). It's cheaper and avoids legal hassles to just trademark a different name.
Admin
Admin
(Because we know it's probably coming sooner or later.)
Admin
"cat <file> |" works basically every single time and takes ~ 1 second extra to type. The cpu time is negligible. Reading the documentation for various commands to find the correct syntax to use to input a file takes much much longer than 1 second, so for those of us who don't know the format of every single command, and who are happy to spend 1 second extra typing a command, it makes sense to use 'cat'.
The real WTF is people like you thinking there is anything wrong with that.
Admin
(gnu) grep -v ^$ -c /var/run/netstat_r.lst ?
Admin
It's funnier as:
unzip | strip | touch | finger | ...
It's all in the delivery.
Admin
This WTF is yet another fine example of a Useless Use Of Cat.
Admin
I can only imagine it would be: ~/../../etc/hosts
of course you could try ~/.someDir/../../../bin/../var/log/../../etc/
Admin
WTF, I have nothing better to do...
#!/bin/bash
input=${*}
usage() { cat<<-!
} begin() { circle }
end() { begin } circle() { jerk } jerk() { fist }
fist() { uranus }
uranus() { wc -l ${input} }
(( ! ${#} )) && usage && exit
while begin; do end done
Admin
From:
DCRoss
Gentlemen, we have a winner in the Rube Goldberg Command entry!! My hat is off to you!
Admin
The real WTF is that he did not use a database.
Admin
My apologies for lack of indentation in the aforementioned utility. I realize that is considered poor practice. I hand my hands full. I'll try to do better next time.
I thought it was file based data, maybe I should parse it as XML? or switch to MongoDB?
Admin
Admin
Why not just let the shell handle the whitespace?
echo
wc -l </var/run/netstat_r.lst
Admin
But you can just use %SYSTEM% to get the location of your SYSTEM32 folder.
Admin
Admin
Luckily, things are much simpler for those of us in Linux-land. As the man page advises, you simply need to type
to discover what wc does.Admin
You can, but people don't. Raymond Chen's explanation.
See also:
Previous discussion on TDWTF, back in 2006.
MSDN on how the folders are used - there are complex things happening under the hood...
Admin
And another RWTF is that the people, who think there's nothing wrong with that, invariably end up at your desk because they don't RTFM.
Admin
Admin
In scripts, I like to use cat at the beginning of a long pipe because it is clearer to me later during maintenance what I wanted. I also think it's a more natural way to think about the process:
Step 1: Start with this data file Step 2: Push it into this program that changes it somehow Step 3: Another transformation etc.
To me, what's in the data file is usually the main idea, not the name of the first program I happen to crunch it with.
So, while I understand some peoples' objections to killing all those cats, I prefer to use them anyway.
Admin
I never got why people don't just use this approach to avoid the extra cat:
<file grep -v "^[ \t]*$" | wc -l