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
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.
Comments