Table of Contents
Toggle# grep root /etc/passwd (To print lines containing word root)
# grep -c root /etc/passwd (To count the no. of lines containing word root)
# grep -v root /etc/passwd (To print all lines except containing matched word “root”)
# grep -cv root /etc/passwd (To count no. of lines occurred by –v)
# grep -i root /etc/passwd (To search by ignoring case sensitive)
# grep -ri root /home/ (Search for matched case in all subdirectories under /home)
# grep "^Oct 29" /var/log/messages (Print all lines which starts with Oct 29)
# grep "re-enable.$" /var/log/messages (Print all lines ends with the word “re-enable”)
# grep "^$" /var/log/messages (Print empty lines available in file)
# grep –c "^$" /var/log/messages (Count of empty lines available)
# find / -type f -size +100M (find files whose size is > than 100M)
# find . -mtime +90 (find file which has been modified more than 60 days)
# find . -mtime -2 (find files which are modified within 2 days)
# find . -cmin -140 (find files which are modified within the mentioned minutes)
# find / -type f -name *.tar.gz -size +100M -exec rm -rf {} \; (find all files having ext. tar.gz and size more than 100M will be find and deleted)
# find . -type f -cmin -200 | xargs tar -cvf /work/script/`date '+%d%m%Y'_archive.tar` (find filed which were modified within 200 minutes and make it archive)
# find . -type f -cmin -190 -exec tar -cvf /work/script/`date '+%d%m%Y'_archive1.tar` {} \; (same work as above)
# find /etc -name "*.conf" |xargs ls –l (To print in list of all conf file available in /etc)
# find /etc -name "*.conf" |xargs -n1 -i cp {} . (To copy output of find command to current location)