This Blog is to share our knowledge and expertise on Linux System Administration and VMware Administration

Wednesday, October 14, 2015

How to find the older files & delete in Linux & Unix

If we have more files in a folder, the normal ls command will not work.

Below command is used to find out the old files.

List the files - 30 days before file

#find /location/to/find/files -type f -mtime +30 -user test -ls  

Delete the files

#find /location/to/find/files -type f -mtime +30 -user test -exec rm {} \

/location/to/find/files - which location you want to find the files
mtime - mention the days, command will find the files older than that days (here 30)
user - if we have more files, mention the user as well

No comments:

Post a Comment