Shell one-liners

Download the plain text (non-html) version of this script.


username and uid sorted by uid

cut, sort, tr

cut -d ':' -f 1,3 /etc/passwd | sort -t ':' -k2n - | tr ':' '\t'




unique words

tr, sed, uniq

tr -c a-zA-Z '\n' > Readme1.txt  | sed '/^$/d' | sort | uniq -i -c





join 2 files where 1 not sorted

sort, join

sort m1.txt | join - m2.txt




memory hog

ps, awk, sort

ps aux | awk '{if ($5 != 0 ) print $2,$5,$6,$11}' | sort -k2n




top 10 largest files || dirs

du, sort, head

du -sk /var/log/* | sort -r -n | head -10





10 most used commands

cat, tr, sed

cat ~/.bash_history | tr "\|\;" "\n" | sed -e "s/^ //g" | cut -d " "


EOF
		

Back to scripts