News for hackers. Stuff that matters.
Re:Explain Shell by jff on Monday December 02, 2013 @12:58PM (#6835255)
I don't know what I was expecting, but one of my most-used command lines, "du -a | grep foo" is pretty uninformative.
Re:Explain Shell by w1ntermute on Monday December 02, 2013 @01:30PM (#6835442)
If you're just trying to locate a file in the current directory, you should probably be using find.
Re:Explain Shell by jff on Monday December 02, 2013 @04:18PM (#6836594)
I remain convinced that "find" also contains a text editor and a Pacman game, but I've never cared enough to read the damn enormous man page. Also, not every system has "find", but everything I've used has "du" and "grep".
Re:Explain Shell by mturmon on Monday December 02, 2013 @04:07PM (#6836530)
Just for definiteness, the equivalent "find" idiom would be:

  % find . -path '*foo*'
You need -path, not just -name, to match the whole name as du does.
Re:Explain Shell by jff on Monday December 02, 2013 @04:19PM (#6836597)
I'll point out that the find command is 21 characters, while mine is only 17. Efficiency!
Re:Explain Shell by mturmon on Monday December 02, 2013 @04:21PM (#6836610)
Yes, you have a point (plus, those stars, they burn the eyes).

But, your detractors will say yours is two processes and theirs is one. Efficiency!

Re:Explain Shell by jff on Monday December 02, 2013 @04:44PM (#6836753)
The kernel could start 100 processes in the time it takes me to type those extra four characters. We won't run out of processes. I did a test, finding .txt files in /usr/share, it took about .25 seconds longer with du and grep, which seems like less than it takes to type 4 more characters.
Re:Explain Shell by girvo on Monday December 02, 2013 @05:38PM (#6837100)
How long does it take you to type a character???
Re:Explain Shell by jff on Monday December 02, 2013 @05:44PM (#6837141)
Assume I type 80 wpm

A word is standardized as 5 keystrokes

80 wpm is therefore 400 keystrokes per minute.

Divide by 60 to get about 6.6 keystrokes per second, or about 0.15 seconds per keystroke.

Therefore it would take about 0.6 seconds to type the four extra characters, giving a net savings to use du+grep instead.

And 80 wpm is probably a rather fast estimate; I'd guess that I type slower when I'm writing commands than when I'm entering English text.

Re:Explain Shell by girvo on Wednesday December 04, 2013 @01:14AM (#6845328)
I must've read it wrong, or you fixed it, 'cause I read it as 25 seconds, hence my question! :)
Re:Explain Shell by w1ntermute on Monday December 02, 2013 @08:38PM (#6837949)
This is all moot, because you can just alias either command to a single letter if you use it that much.
Re:Explain Shell by mturmon on Monday December 02, 2013 @06:49PM (#6837490)
I will switch immediately! ;-)
Re:Explain Shell by deelowe on Monday December 02, 2013 @03:06PM (#6836153)
"grep searches the named input FILEs (or standard input if no files are named..." Important bit being "or standard input."

Also, what an odd one-liner. What's the use case for this that makes it such a common command: file names and sizes for all files matching a pattern beneath the current subdirectory (and all subdirectories and files within subdirectories matching that same pattern)? Genuinely curious.

Re:Explain Shell by evanspa on Monday December 02, 2013 @01:06PM (#6835306)
Tried it. The explain read-out seemed reasonable. Care to elaborate how it wasn't informative?
Re:Explain Shell by jff on Monday December 02, 2013 @01:12PM (#6835340)
The explanation for "du" and its -a flag make it sound like I'm trying to find out how much disk space my files are using. Fine, that's the usual usage, but the point here is that it lists out every file under the current directory.

The bigger problem is grep. We're told that grep prints lines matching a pattern, great. But then the explanation of the arguments makes it sound, to the uninitiated, like I'm giving "foo" as the filename, because the site doesn't include the actual grep syntax.

It doesn't really explain what the command line is doing. It does seem to do a decent job of telling someone who's already fluent in shell usage the specific meaning of all options given. That's actually pretty important these days where any given GNU util will have flags for every single letter of the alphabet in both upper and lower case.

Re:Explain Shell by ygra on Monday December 02, 2013 @02:54PM (#6836062)
That's not really solvable in this case, though. All explainshell has are the man pages of the commands. It cannot know how they will interact with each other. It should be at least semi-possible in PowerShell (because you have output type information and parameter type information), but I hit a roadblock with ExplainPS a while ago and haven't had the time to resurrect it.
Re:Explain Shell by wilcox on Tuesday December 03, 2013 @12:46AM (#6838814)
Perhaps you should go for find . / -name filename instead. Using du -a | grep filename works for sure, but it a bit of hack.
Re:Explain Shell by p9idf on Monday December 02, 2013 @01:34PM (#6835473)
I think I can one-up you.

  (while :; do cat ; sleep 2 ; done) <file
Re:Explain Shell by JoshTriplett on Monday December 02, 2013 @01:56PM (#6835612)
How is that not "tail -f file"?
Re:Explain Shell by abraininavat on Monday December 02, 2013 @01:50PM (#6835569)
I'm curious why this is one of your most-used commands. If you want to know the sizes of all files matching 'foo', this is a horribly inefficient way of going about it.