You're viewing a comment by Peter Krumins and its responses.

October 13, 2012, 15:38

1. I love when each command does just one thing, and I love to pipe things together.

I could have written it as a Perl one-liner:

history | perl -lne 's/\d+//;s/^\s+//;s/\s\s/ /; $count{$_}++; END { print "$count{$_} $_" for (sort { $count{$a} <= $count{$b} } keys %count )[0..10] }'

2. Good example of combining commands together.

Comment Responses

lava Permalink
November 04, 2012, 20:14

Also, it would be an overkill to use
history | sort | uniq -c | sort -rn

because, as you stated in the article, history is printing .bash_history to the screen. For most users it would be better to run:
$ sort .bash_history | uniq -c | sort -rn

because this will exclude one pipe.

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "computer_334": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.