Wednesday, 26 August 2009

My ~]# ./Shell One Liners

This is going to be a long list of some of the shell one liners that I have used at one time in my *nix life.

1. ps axho args | awk /ssh/'{print $1}'
2. for i in AIX*; do mv $i BSD${i:3}; done ## or u can use {i#AIX}
3. sed -i s/AIX/BSD/ BSD*
4. kill `ps aux | awk /$1/'{if ($3+0>'"$limit"') {print $2} }'`
5. for i in *.frm; do touch ${i%.frm}.{MYD,MYI}; done
6. awk '/^iface bar/,/^$/ {print}'
7. find /home/ -name '*:*' -exec rename s/:/-/ {} \;
8. sed '/^$/d' /path/to/currentfile | sed '1,8d' | sed 'N;$!P;$!D;$d' > /path/to/newfile
9. find /mytopdir -depth -type d -empty -exec rmdir {} \;
10. find . -type f -newermt 2007-06-07 ! -newermt 2007-06-08
11. find ./ -type f -ls |grep '19 Jun'
12. find . -type f -mtime $(( ( $(date +%s) - $(date -d '2010-06-25' +%s) ) / 60 / 60 / 24 - 1 ))
13. ifconfig -a | grep inet | grep -v '127.0.0.1' | awk '{ print $2}'
14. sed -i 's/StringA/StringB/g' ` grep -ril 'StringA' /homes/myhome/* ` 
15. find / -cmin -1440 -size +5000000c -print
16. for i in `ls /homes/`; do find /homes/$i/ -name "*R3D*" -mtime +730 -exec rm {} \;; done
17. cd /home/user && rename : _ *:*
18. for i in `find /home/user/ -name '*:*' -print`; do mv $i ${i//:/_}; done

No comments:

Post a Comment