How to list files for particular duration of time .?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to list files for particular duration of time .?
# 1  
Old 05-16-2014
How to list files for particular duration of time .?

Hi

there is a lot of file dated from last week till ofpresent date.

if i want to list only last 3 days files using ls command how can i do it

please suggest. below is the list of the file.

and i want to list files from MAy 12 to May 16.

Code:
 
Nov 22 2011  NSSM.UPPLSCPLB81
Jan 12 2012  CSA.UPPLSCPLB81.
Sep 16 2013  RCM.UPPLSCPLB81.
Dec 11 14:19 fdd
Feb 04 23:51 RCM.UPPLSCPLB81.
May 08 18:15 NSSM.UPPLSCPLB81
May 08 18:15 NSSM.UPPLSCPLB81
May 12 17:25 NAVG.UPPLSCPLB8
May 12 17:25 NSSP.UPPLSCPLB8
May 12 17:25 NSSM.UPPLSCPLB8
 May 13 00:00 NSSP.UPPLSCPLB81
 May 13 00:14 RCM.UPPLSCPLB81.
 May 13 00:29 RCM.UPPLSCPLB81.
 May 13 00:30 NAVG.UPPLSCPLB81
May 14 17:00 NSSM.UPPLSCPLB81
May 14 17:08 RCM.UPPLSCPLB81.
May 14 17:24 RCM.UPPLSCPLB81

.
# 2  
Old 05-16-2014
Code:
find . -type f -mtime -3 -ls

# 3  
Old 05-16-2014
If you have a fixed date range (not just up to current date) you can use a combination of touch & find

For touch the date format is [[CC]YY]MMDDhhmm[.SS] where the bits in square brackets are options if you are giving the current century, year or are happy that the seconds with be zero.

So for today 16/05/2014 @ 10:45:30, if we want to go back two days and find things less than three days before that:-
Code:
touch -mt 201405141045.30 /tmp/my_list_endeth
touch -mt 201405111045.30 /tmp/my_list_started
ls -l /tmp/my_list_*

This should give you two files with a date/time range. You can then use find to select the files you want:-
Code:
find /path/to/look -type f -newer /tmp/my_list_started ! -newer /tmp/my_list_endeth

All the flags for find are in the manual pages, but the ones I've shown here are:-
  • -type f. . . . .- Find only files, not directories, pipes, soft links, devices etc.
  • -newer . . . . . - Find items with a modified time more recent than the referenced file
  • ! -newer . . . .- Find items with a modified time not more recent (i.e. older) than the referenced file



I hope that this helps,
Robin
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to calculate time duration in Linux?

I want to calculate duration for below file in this format SID | Date | Starttime |Date |End time 1607 |2019-04-05|13:06:42|2019-04-05|13:07:12 2327 |2019-04-05|13:57:26|2019-04-05|13:57:43 O/p should be like this: SID | Date | Starttime |Date |Endtime... (4 Replies)
Discussion started by: anupmishra
4 Replies

2. Shell Programming and Scripting

Perl ::duration of time in between dates

Hello All, I have two strings with date and time as follows.. $starttime= "06/11/2013 "; $starttime= "05:15"; $enddate="06/12/2013"; $endtime="04:45"; dates are in mm/dd/yyyy format and time in military format. and I am looking the duration of time(in minutes) in between dates. ... (3 Replies)
Discussion started by: scriptscript
3 Replies

3. Shell Programming and Scripting

Getting the Start, End time and duration using date command

Oracle Enterprise Linux We want to track how long a process takes to complete its execution. This is what we want in the schell script Before the process is started , get the time with date, hours and minutes execute the process After the process has ended , get the time with date,... (5 Replies)
Discussion started by: omega3
5 Replies

4. Shell Programming and Scripting

Calculating the epoch time from standard time using awk and calculating the duration

Hi All, I have the following time stamp data in 2 columns Date TimeStamp(also with milliseconds) 05/23/2012 08:30:11.250 05/23/2012 08:30:15.500 05/23/2012 08:31.15.500 . . etc From this data I need the following output. 0.00( row1-row1 in seconds) 04.25( row2-row1 in... (5 Replies)
Discussion started by: ks_reddy
5 Replies

5. UNIX for Advanced & Expert Users

time duration of being online of a particular user given the user name

in a multi user system of 3 users X,Y,Z, if i know that X is presently online, is it possible to determine for how long has he been online? i mean the time duration (3 Replies)
Discussion started by: arindamlive
3 Replies

6. Shell Programming and Scripting

How to get time duration between two human readable time stamp in Unix?

Here is two time I have: Jul 12 16:02:01 Jul 13 01:02:01 and how can I do a simple match to get difference between two time which is 09:00:00 Thanks in advance. (3 Replies)
Discussion started by: ford99
3 Replies

7. Shell Programming and Scripting

List files and display last modify time in a particular format

hi everyone, can someone suggest how i can list the contents of a directory and display their corresponding last modify time in the format yyyymmddhhmm? thanks in advance! (16 Replies)
Discussion started by: Deanne
16 Replies

8. UNIX for Dummies Questions & Answers

List files with date and time stamps only

Hi there, I'm using terminal on mac and using the ls -l command to list all the files in a directory. However, I only want to display the date and time stamp of each file rather than permissions, owner, group etc... Is this possible? Many thanks in advance Dave (2 Replies)
Discussion started by: davewg
2 Replies

9. Shell Programming and Scripting

to get list of files of a perticular range of time

hi, how to list the files which has been created or accessed before 6 months thanks (1 Reply)
Discussion started by: useless79
1 Replies

10. Solaris

Finding list of modified files for a particular time duration

Hi , I am trying to find out the List of files modified or added aftter installation of any component on SUN solaris box . But i am not able to do it using ls or find command . Can somebody help me out ? Thanks Sanjay Gupta (2 Replies)
Discussion started by: sanajyg_mnit
2 Replies
Login or Register to Ask a Question