![]() ![]() If you just have xargs, then pipe to xargs (adding -no-run-if-empty if the GNU extensions are available). If you have -delete, that’s the definite high-performing version. We’ll use this in order to figure out what files are older than a certain number of days, and then use the rm command to delete them. If there is no files exists to remove older than 10 days, It should not do anything. ![]() I don’t think it was present in 4.4BSD, nor is it present in Posix. 1 05-23-2012 rajeshjohney Registered User 3, 0 Delete files older than 10 Days in a directory Hi All I want to remove the files with name like data.csv from the directory older than 10 days. ![]() Executed the above script (thinking it is something name related) and trying to delete files that are older than 3 days. delete all the subdirectories older than x days as well, you need to use rm -rf command. I did a rsync of the undo folder on a test one. If you would like to venture further into the dangerous territory i.e. mtime - Indicates the file modification time and is used to find files older than 30 days. Here, dot (.) - Indicates the current directory. I have CSV files get updated every day and we process the files and delete the files older than 30 days based on the date in the filename. Of course you can use rm command: find /home/incoming/images/ -type f -iname '*.jpg' -mtime +30 -exec rm should still be considered relatively expensive, and I wouldn’t use it unless with a simple command like rm, but there might be other instances where you want to do something complicated there. All the files older than 3 days will be deleted. The above command will find and display the older files which are older than 30 day in the current working directory. This question already has answers here : Closed 3 years ago. First of all, list all files older than 30 days under /opt/backup directory. Also, if required you can delete them with a single command. Just use find with -mtime option: CentOS Linux: Delete All *.png Files Older Than 30 Days find /home/incoming/images/ -type f -iname '*.png' -mtime +30 -delete Using the find command, you can search for and delete all files that have been modified more than X days. ![]()
0 Comments
Leave a Reply. |