Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss] inventory of most-used programs; bash quoting problem



I was trying to do the following to report on the most used commands (for
each user found in /home).

find /home -maxdepth 2 -name '.bash_history' -exec bash -c 'echo -e
"\n$1\n"; cat "$1" | awk '{ print $1 }' | sort | uniq -c | sort -rn | head
' _ '{}' \;

But I couldn't figure out how to get awk quoting to work inside the bash -c
string literal.  I looked it up, so now I know how to do it. I know it's
been discussed on this list before.  I just throw it out there as a
refresher :-)

Answer: Use these four characters '\'' to represent a single quote (inside
a single quoted string)

(I think you can also use the octal representation of a quote character,
but that's not as easy to remember.)

Greg Rundlett



BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org