How do I delete 2 days old files in Linux?

How do I run Adobe XD on Ubuntu?

How do I remove old days from a file in Linux?

If you want to delete files older than 1 day, you can try using -mtime +0 or -mtime 1 or -mmin $((60*24)) .

How do I delete files older than 2 days Linux?

Explanation

  1. The first argument is the path to the files. This can be a path, a directory, or a wildcard as in the example above. …
  2. The second argument, -mtime, is used to specify the number of days old that the file is. …
  3. The third argument, -exec, allows you to pass in a command such as rm.

How do I delete files older than 3 days UNIX?

4 Answers

  1. Also use -type f to delete files only (and keep sub directories) …
  2. Alternatively, if you want to do the same for all files NEWER than five days: find /path/to/directory/ -mindepth 1 -mtime -5 -delete. …
  3. @uom-pgregorio I would suggest putting the path in quotes.

How do I delete 7 day old logs in Linux?

-mtime +7 : only consider the ones with modification time older than 7 days. -execdir … ; : for each such result found, do the following command in … . rm — ‘{}‘ : remove the file; the {} part is where the find result gets substituted into from the previous part.

THIS IS INTERESTING:  How can I run Linux on Windows without Virtual Machine?

How do I delete one week old files in UNIX?

You could start by saying find /var/dtpdev/tmp/ -type f -mtime +15 .

4 Answers

  1. -exec rm -f {} ; (or, equivalently, -exec rm -f {} ‘;’ ) This will run rm -f on each file; e.g., …
  2. -exec rm -f {} + …
  3. -delete.

How do I bulk delete files in Linux?

To delete multiple files at once, use the rm command followed by the file names separated by space. When using regular expansions, first list the files with the ls command so that you can see what files will be deleted before running the rm command.

How do I delete a directory more than 30 days in Unix?

You should use the command -exec rm -r {} ; and add the -depth option. The -r option to rm remove directories with all the content. The -depth option tell find to elaborate content of folders before the folder itself. That’s almost perfect, thanks.

How do I get rid of log files older than 7 days?

Break Down Of Command

Here we used –mtime +7 to filter all files which are older than 7 days. Action -exec: this is generic action, which can be used to perform any shell command on each file which is being located.