1830350 Members
2550 Online
110001 Solutions
New Discussion

list by a date range?

 
SOLVED
Go to solution
bob the spod
Occasional Advisor

list by a date range?

is it possible (I have been told everything is possible in UNIX) to do a list of files which are from a specified date?

when I try an ls -ltr or ls -l etc I cant see back far enough to get the files I am looking for.

help!
Bob
you make me feel like dancing (gonna dance the night away!)
8 REPLIES 8
Patrick Wallek
Honored Contributor

Re: list by a date range?

Have you tried piping your command to 'more'?

# ls -lt | more

# ls -ltr | more

The -t option will sort everything by date, and 'r' reverses it.
Pete Randall
Outstanding Contributor
Solution

Re: list by a date range?

Bob,

For a specific date you could use grep: "ls -l |grep 'Feb 20 1997'".


Pete


Pete
Patrick Wallek
Honored Contributor

Re: list by a date range?

Hmm....To quick on the submit this morning.

The only way I can really think of to look for a specific date is with 'grep'.

# ls -l | grep "Oct 9"
# ls -lt | grep "Aug 31"

Note that if the date is a single digit number, then there are 2 space between the Month and the day.
john korterman
Honored Contributor

Re: list by a date range?

Hi,
If you do not mind a bit of counting, e.g. list files whose last rev date is 3:
# find -type f -mtime 3 -exec ls -l {} \;

regards,
John K.
it would be nice if you always got a second chance
Mark Grant
Honored Contributor

Re: list by a date range?

Well,

"ls -ltr | more" will at least allow you to page throught the output (press space) but another and somewhat duller approach is

"find / -mtime X -print" will list files modified in the last X days though i think
"find / -ctime X -print" is more likely to end up meaning created in the last X days (it doesn't but most of the time the result is the same)
Never preceed any demonstration with anything more predictive than "watch this"
john korterman
Honored Contributor

Re: list by a date range?

Hi again,
sorry, I meant "files whose last revision date was three days ago".

regards,
John K,
it would be nice if you always got a second chance
Robert-Jan Goossens
Honored Contributor

Re: list by a date range?

Hi Bob,

You can use,

# ls -la | grep "Jan 22"

Hope it helps,

Robert-Jan.
Jeff Schussele
Honored Contributor

Re: list by a date range?

Hi Bob,

Best way I can think of to do this is with touch & find.
touch -t 2 files, one at each end of the range & then use find with -newer for the low end & ! -newer for the high end plus an AND operator.
Little more work, but can be took all the way down to the seconds level & easily scripted.

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!