Skip to content

Shell

All things shell

Miscellenous / Glorious one-liners


Finds anything in current directory that isn't zipped and zips it

1
find . -type f ! -iname '*.gz' -exec gzip "{}" \;


Get external IP from CLI

1
curl http://checkip.amazonaws.com/
1
dig +short myip.opendns.com @resolver1.opendns.com


Move files based on date

1
mv `ll | grep 'Jan 31' | awk '{print $9}' [DEST]`


Puppet nuke

1
yum -y remove $(rpm -qa | egrep 'puppet|^pe-') ; rm -rf /etc/puppetlabs /opt/puppetlabs /var/log/puppetlabs /etc/sysconfig/p{e-*,uppet}


Print SWAP usage by process

1
for file in /proc/*/status; do awk '/VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | sort -k 2 -n -r | less


Test mail CLI

1
echo "Subject: E-mail test" | sendmail -v $EMAIL_ADDRESS
1
echo "Special delivery" | mailx -s "Hello" -a testfile1 $EMAIL_ADDRESS


Shell keepalive

1
while true; do echo jh; sleep 30; done