Re: [Hampshire] Top ten commands in history

Top Page
Author: Neil Ferguson
Date:  
To: Hampshire LUG Discussion List
Subject: Re: [Hampshire] Top ten commands in history

Reply to this message
gpg: failed to create temporary file '/var/lib/lurker/.#lk0x57336100.hantslug.org.uk.13886': Permission denied
gpg: keyblock resource '/var/lib/lurker/pubring.gpg': Permission denied
gpg: Signature made Wed Jan 31 10:56:02 2007 GMT
gpg: using DSA key B8D12EB98648D2D8
gpg: Can't check signature: No public key
On Wed, 2007-01-31 at 00:24 +0000, Chris Dennis wrote:
> We also learn that su and sudo hide the interesting part of the command. 
>   Can someone who is clever at awk change the script
>     history | awk '{print$2}' | sort | uniq -c | sort -rg | head -n
> to pick out the second word if the first is either 'su' or 'sudo' (or a 
> Bash-style 'ENVVAR=value' prefix)?


history | awk '$2 ~ /^(sudo|[^[:blank:]]+=)/{print $2 " " $3;next}{print
$2}' | sort | uniq -c | sort -rg | head -n 10

Something like that should probably do it I'd imagine - only very
briefly tested though. Also, I've only picked out sudo not 'su' as
you'd have to cope with 'su -', 'su -c', 'su user' etc. for it to be
useful I guess.

Cheers,


Neil