I want to list files in the current directory between a date range (e.g. Sep 20-25). Is the way to do this to use ls -l and then use awk to grab the columns I want and then do a date comparision or is there an easier way?
Here are several examples:
You are probably more interested in this flavor....
The find command is really powerful as you can search for files modifed down to an exact (well almost) time using a reference file
touch -t 03201600 /tmp/datefile
creates a file with timestamp of March 20, 4:00
find . -newer /tmp/datefile -print
find files newer than timestamp of datefile - granular to within one minute
This was good stuff.. but what do i do to find files that are older than today and move them to another folder. today's files should be there in the directory but older ones to be moved out !!..
This was good stuff.. but what do i do to find files that are older than today and move them to another folder. today's files should be there in the directory but older ones to be moved out !!..
This will take start in "/your/directory", find all files (-type f) which creation date (-ctime) is older than today (+1) and perform (-exec) the command stated up to the "\;" for every file found that way. The name of the found file will be set in plcae of the "{}".
Best thing to learn this comand is to try it out (replace the "mv" with something less intrusive) with different parameters and see what it does.