

- #Find files by date linux compress old how to#
- #Find files by date linux compress old archive#
- #Find files by date linux compress old free#
#Find files by date linux compress old archive#
With GNU date and Bash we could do something like this to add each file to an archive corresponding to the file's date: for f in do zip (date -r 'f' +F).zip 'f'. To find the files that have been changed (with the files data modification time older than) in the last N days from a directory and subdirectories, use: The usual find -mtime is a bit hard to use here, since it only tests age relative to current point in time.
#Find files by date linux compress old how to#
It is much easier than my method.This article explains how to find all files in a directory that have been changed in the last N minutes or days, or those with a modification date older than N minutes or days, with examples.

To find the oldest file in the entire root (/) file system, run: $ sudo find / -type f -printf '%T+ %p\n' | sort | head -n 1Ī fellow Linux user has pointed out how to find the oldest or newest files in a directory in the comment section below. +18:28:20.5162190000 /home/sk/ostechnix/ubuntu.jpg maxdepth 1 -mtime +15 -type f -printf 'TYTmTd p ' while read date name do zip date name done File's last modification time in Ymd format. Likewise, to find the top five oldest files in a given directory, just run: $ find /home/sk/ostechnix/ -type f -printf '%T+ %p\n' | sort | head -n 5
#Find files by date linux compress old free#
Instead, it uses the file modification date to find it.ĭownload - Free Cheat Sheet: "Linux Command Line Cheat Sheet" While the details are unimportant it is worth understanding that anything on a Linux. files (name, path, date, time of last modification, protection, and check. Please note that Linux doesn't find the oldest file by using the file creation date. Youve probably noticed that the date on this file is a bit suspect. References to MacOS below generally refer to MacOS versions older than OS X. The above command returned the following output: +13:42:40.0000000000 /home/sk/ostechnix/Absolute FreeBSD_ 2nd Edition.pdfĪs you see in the above output, Absolute FreeBSD_ 2nd Edition.pdf is the oldest file in /home/sk/ostechnix/ directory. Here, dot (.) - Represents the current directory. mtime +30 -print The above command will find and display the older files which are older than 30 day in the current working directory. I interpret after as newer than a specific. Find And Delete Files Older Than X days In Linux First, let us find out the files older than X days, for example 30 days.

