How do I get 30 days old files in UNIX?

Where is all files older than 30 days Linux?

You can use the find command to search all files modified older than X days. And also delete them if required in single command. First of all, list all files older than 30 days under /opt/backup directory.

How do I find files older than 5 days in Unix?

The second argument, -mtime, is used to specify the number of days old that the file is. If you enter +5, it will find files older than 5 days. The third argument, -exec, allows you to pass in a command such as rm. The {} ; at the end is required to end the command.

How do I find files older than a certain date in Unix?

this find command will find files modified within the last 20 days.

  1. mtime -> modified (atime=accessed, ctime=created)
  2. -20 -> lesst than 20 days old (20 exactly 20 days, +20 more than 20 days)

How do I find files older than 7 days UNIX?


  1. find : the unix command for finding files/directories/links and etc.
  2. /path/to/ : the directory to start your search in.
  3. -type f : only find files.
  4. -name ‘*. …
  5. -mtime +7 : only consider the ones with modification time older than 7 days.
  6. -execdir …
IT IS INTERESTING:  How do I change administrator to owner?

Where are 2 days old files Linux?

4 Answers. You could start by saying find /var/dtpdev/tmp/ -type f -mtime +15 . This will find all files older than 15 days and print their names. Optionally, you can specify -print at the end of the command, but that is the default action.

How do I list old files in Linux?

Find and delete files older than X days in Linux

  1. dot (.) – Represents the current directory.
  2. -mtime – Represents the file modification time and is used to find files older than 30 days.
  3. -print – Displays the older files.

What is awk Unix command?

Awk is a scripting language used for manipulating data and generating reports. The awk command programming language requires no compiling, and allows the user to use variables, numeric functions, string functions, and logical operators. … Awk is mostly used for pattern scanning and processing.

How do I delete old files in UNIX?

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

What is Newermt in Unix?

a The access time of the file reference B The birth time of the file reference c The inode status change time of reference m The modification time of the file reference t reference is interpreted directly as a time.

How do I zip a 10 day old file in Unix?

Gzip is the utility provided by Operating system linux, unix for gzip the files and reduce the size of the files with compression method or algorithms. You can use find command with combination of gzip command to compressed the files older than 1o days by providing parameter mtime with find command.

IT IS INTERESTING:  How do I remove a local account as administrator in Windows 10?

How do I move a file from a specific date in Unix?

How it works

  1. find . – mindepth 1 -maxdepth 1. …
  2. -mtime -7. This tells find to select only files less than seven days old.
  3. -exec mv -t /destination/path {} + This tells find to execute a mv command to move those files to /destination/path .
Operating systems are simply