Live data from Hacker News

Top Unix Command Line Utilities

blog.coldflake.com

61–65 of 65 posts

Re: Top Unix Command Line Utilities

#61
post #48

The second #6 example, the one with xargs, is wrong. Xargs(1) doesn't necessarily create a single du process, it might create several.

I was wondering about that, but is it really wrong? From what I found in the "BSD General Commands Manual": Any arguments specified on the command line are given to utility upon each invocation, followed by some number of the arguments read from the standard input of xargs. The utility is repeatedly executed until standard input is exhausted. and -P maxprocs Parallel mode: run at most maxprocs invocations of utility…

If the utility is repeatedly executed then by definition it can't be a single process.

Re: Top Unix Command Line Utilities

#62
post #60
post #44

Earlier quoted context omitted.

One reason might be that bash reads this whole file into memory on interactive startup and rewrites it completely when shutting down.

I second this, I think it is good practice to rotate the history file manually when it reaches several MBs. (Using zsh, the main symptoms of a large history file is sluggishness when using ^R and a lag of a few tenths of a second when closing a terminal.)

For now I don't feel any annoyance, the shell startup is instantaneous and it closes instantaneously as well. If I'm starting to feel a slow down I might rotate the log, but I guess that's not happening soon.

Re: Top Unix Command Line Utilities

#63
post #10

Where's the love for awk? It has been tucked away in a sub item but doesn't deserve first class status?

actually there is heaps of love for awk... so much actually that I'd rather spend a whole post on it than to "just" make it one item :)

Motivated by your list, I went through my history to pull some awk snowclones http://news.ycombinator.com/item?id=4989524

Re: Top Unix Command Line Utilities

#64
post #48

The second #6 example, the one with xargs, is wrong. Xargs(1) doesn't necessarily create a single du process, it might create several.

I was wondering about that, but is it really wrong? From what I found in the "BSD General Commands Manual": Any arguments specified on the command line are given to utility upon each invocation, followed by some number of the arguments read from the standard input of xargs. The utility is repeatedly executed until standard input is exhausted. and -P maxprocs Parallel mode: run at most maxprocs invocations of utility…

Even in sequential mode, for a sufficiently long input xargs will invoke the command multiple times to comply with kernel limits on command line length.

Re: Top Unix Command Line Utilities

#65
post #6

My 2012 top, in order of usage: joe, ls, cd, time, cdbdump, tail, more, cat, rm, grep, wc, apachectl restart, find, curl, chmod, history, mv, locate, cpan, apt-get, pwd But the most useful one is a command line Perl utility I called "flt" that executes a block of perl code for each in the stdin. cat file.txt | flt ' $line=~ s|\s+| |gsi; print $line."\n"; ' That would compact free spaces find . | flt ' if (-f $line) {…

Are you familiar with perl's -n and -p switches? http://perldoc.perl.org/perlrun.html#*-n* Those "flt" lines could be written perl -lpe 's|\s+| |gsi' file.txt find . | perl -ne 'if (-f) { print -s }' (-l chomps the incoming newlines, and puts them back on the output) Of course, "perl -ne" is longer than "flt", and I appreciate all this implicit use of $_ is not to everyone's tastes.

Yes, but I bundled slightly better syntactic sugar in my tool. It's the same, in essence.
Post reply on HN