Saturday, June 16

Find Command

1)Find command to check biggest files in a directory
 find . -type f -exec ls -s {} \; | sort -n -r | head -5

2)Find Command to get the recent modified data
--------------------------------------------------------
-mtime +60 ----find 60 days ago modified data
-mtime -60-----find 60 days below modified data.
-mtime 60 ------find modified data exactly 60th day.
--------------------------------------------------------
Ex:
To find the last modified data under root folder

find / -mtime -1-----find last 1day modified data
find / -iname "*.txt" -mtime -60----- find tha last 60 days modified data.

3)How to find and remove old files on Unix server

To find old files before 90 days
find {directory to search in} -atime +90

TO remove files before 90 days
rm 'find {directory to search in} -atime +90'

Eg:-find < APP-DIR > /pdm/ -atime +90
It displays files used before 90 days in above directory

rm 'find
< APP-DIR > /pdm/ -atime +90'
It removes files before 90 days in above directory

No comments:

Post a Comment