"\r" doesn't work either. It's just not interpreting those kind of escapes. I get lines like this:
historyrsed "s/^[0-9 ]*//"rsed 's/ *r*/\r/g'rless
The for loop is a good idea, though I prefer the "while read" idiom since it fits in with the pipeline better: ...
| awk '{print $1}' \
| while read line; do which $line; done \
...
That finally works for me. Here's the whole thing: history \
| sed "s/^[0-9 ]*//" \
| perl -pe 's/ *\| */\n/g' \
| awk '{print $1}' \
| while read line; do which $line; done \
| sed "s.^/usr.." \
| grep ^.bin \
| sed "s/^.*\///" \
| sort \
| uniq -c \
| sort -rn