top of page

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

  • Writer: Jatin Madaan
    Jatin Madaan
  • Feb 14, 2019
  • 1 min read

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.


Comentários


  • linkedin

©2019 by Jatinmadaan

bottom of page