FIND & DELETE
Find and delete files with .aud extension in some path older than 14 days:
find /oracle/audit -name "*.aud" -mtime +14 -exec rm {} \;
When the number of files is huge, the script above might complain. So, it might be a good idea to export the names of the files to be deleted into a file and then execute the delete command. Optionally, we can even tar them before deleting:
find /oracle/xmlpath -name "*.xml" -mtime +30 -print > /oracle/xmlpath/thefilestobedeleted.lst tar -czf /oracle/xmlpath/filesabackup.tar.gz -T /oracle/xmlpath/thefilestobedeleted.lst xargs rm -rf < /oracle/xmlpath/thefilestobedeleted.lst
List the contents of a file by removing the empty lines and the lines that start with a specific character (commented out lines for ex.) In my case it is the # character:
grep '^[[:blank:]]*[^[:blank:]#;]' mytext.txt
Find a specific string in all of the files in a folder:
grep -<options> <path> -e <pattern> grep -Rnw . -e 'kjqghd' grep -Ril . -e 'kjqghd'
-r or -R is recursive,
-n is line number
-w stands for match the whole word.
-i ignore case
-l stands for "show the file name, not the result itself".
Count the number of files and folders in a folder:
ls | wc -l