Posts Tagged ‘FIND FILES BETWEEN TIME FRAMES’

FIND FILES BETWEEN TIME FRAMES

November 13th, 2021, posted in Solaris
Share

Example 1:
You want to find files between specific time frame and move them to different directory. You can use the -newer or -newmt option with find command.

In this below example I am creating 2 dummy files with different timestamp and moving any files found between those time frames are moved to directory /var/tmp/Archive.

touch -t 201310040000 first
touch -t 201410040000 last
# find . -newer first ! -newer last -type f -exec mv {} /var/tmp/Archive;

Example 2:
In this example, I am listing files between Oct 04 2013 and Oct 04 2014.
Sed command is for replacing dot ‘.’ with blank space before the file name.

#find . -newermt “2013-10-04 00:00:00” ! -newermt “2014-10-04 00:00:00” | sed ‘s/.///g’|xargs ls -l


If you require more information or any questions on the above commands please comment below.

Reference: http://linux.about.com/od/commands/l/blcmdl1_find.htm

Share