Nuclear Rooster

command line tidbits

AWK

Print out long lines
awk 'length > 200' filename

Print first column
awk '{print $1}'

Remove long Lines
awk '{ if(length < 6) {print $0 } else {next} }' < long_lines.txt > trimmed.txt

Remove long lines, and save them off
awk '{ if(length < 200) {print $0 >> "trimmed.txt"} else {print $0 > "long_lines.txt"} }' < input.txt

Sort

Sort nth column as an number, and reverse (descending)
sort -n -r --key=N

Sudo

Log in as another user, use their home directory.
sudo -H -u someUser bash -l

Find

Remove files older than 5 days:
find /path/to/files* -mtime +5 -exec rm {} \;

Remove Files larger than 10k:
find /path/to/files -size +10k -type f -exec rm -f '{}' \;