top of page
Writer's pictureJatin Madaan

Unix Command to delete all files which are more than x days old.

While deleting files which are x days sometimes we may get "Argument list too long error" so to avoid this we can use xargs function of unix .


Actual command :

$ find *.txt -mtime +14 | xargs rm



Unix command to remove files which are more than x days old.


Above command will remove all *.txt files (in present working directory ) which are more than 14 days old .


For removing files from another directory make sure to provide absolute path -- also make sure file path is not parameterised as it could be a case where a blank parameter is passed and everything from entire root is deleted.


24 views0 comments

Comments


bottom of page