Select all files in a folder based on creation date (ls command)


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Select all files in a folder based on creation date (ls command)
# 1  
Old 06-24-2013
Question Select all files in a folder based on creation date (ls command)

Hi All,

<Re-posting in Correct group>

I'm trying to select all the files in a folder that starts with a particular name format and are created in a gven date range using 'ls' command...but i'm not successful....

Example : I'm trying to see all the text files in a folder who names start with abc (abc*.txt) and which are created in a given date range ( created between 01-May-2013 and 31-May-2013)

Can any of you please help me with this?
I really appreciate your help on this.


Thanks & Regards
# 2  
Old 06-24-2013
Check this one

Code:
ls -lrt abc*txt | grep "May"

Thanks

Last edited by radoulov; 06-24-2013 at 05:44 PM..
This User Gave Thanks to senthil.ak For This Post:
# 3  
Old 06-24-2013
That's not a robust solution. What if there's a username or group named May or containing such a substring? It could trigger false positives. What if May occurs in the wildcard portion of abc*.txt? Another possible false positive. The format of the date in ls depends on locale. It may use 05 instead of May.

Then again, perhaps your suggestion is good enough for the OP's needs.

Regards,
Alister
This User Gave Thanks to alister For This Post:
# 4  
Old 06-24-2013
Quote:
Originally Posted by senthil.ak
Check this one

ls -lrt abc*txt | grep "May"

Thanks


Hi Senthil,

Thank you for your reply.

The command is providing me the list of files that have both the strings 'abc' and 'May' in the file name. But, what i'm looking for is the list of files that have the string 'abc' in the file name and are created in May.
(These files do not have the string 'May' in the file name)
# 5  
Old 06-24-2013
if possible please paste the sample file list from the directory.
# 6  
Old 06-24-2013
Quote:
Originally Posted by Satya C1
The command is providing me the list of files that have both the strings 'abc' and 'May' in the file name. But, what i'm looking for is the list of files that have the string 'abc' in the file name and are created in May
I provided a solution in your duplicate post.

Regards,
Alister
This User Gave Thanks to alister For This Post:
# 7  
Old 06-25-2013
Quote:
Originally Posted by senthil.ak
if possible please paste the sample file list from the directory.
Senthil...I have only a few files with the string "May" in the file name..So the command you gave me worked with a little manual work.....Thanks a lot....

---------- Post updated at 11:17 PM ---------- Previous update was at 11:15 PM ----------

Quote:
Originally Posted by alister
I provided a solution in your duplicate post.

Regards,
Alister
Thank you for your response Alister...
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Delete oldest folder based on folder named as date

Hi, I have a script doing backup to synology server, the script create new folder each day with the date as being folder name i.e. 2018-07-30. Just before creating the new folder I want the script to find the oldest folder from the list and delete it including its content. for example... (3 Replies)
Discussion started by: humble_learner
3 Replies

2. Shell Programming and Scripting

Bourne returning files based on creation date

I'm wanting to write a bourne shell script that takes in two command line arguments - a directory and a file. With this I want to return a list of files within the directory that are older (based on creation date) than the given file, and print the number of files that have not been listed (they... (4 Replies)
Discussion started by: britty4
4 Replies

3. UNIX for Dummies Questions & Answers

Unable to find files, those can be present anywhere in the directory tree,based on its creation date

Hi I am unable to find files, those are present anywhere in the same directory tree, based on the creation date. I need to find the files with their path, as I need to create them in another location and move them. I need some help with a script that may do the job. Please help (2 Replies)
Discussion started by: sam192837465
2 Replies

4. Shell Programming and Scripting

Move files from one directory to another based on creation/modification date

Hi All, Really stuck up with a requirement where I need to move a file (Lets say date_Employee.txt--the date will have different date values like 20120612/20120613 etc) from one directory to another based on creation/modification dates. While visiting couple of posts, i could see we can... (3 Replies)
Discussion started by: dsfreddie
3 Replies

5. Shell Programming and Scripting

Need script to select multiple files from archive directory based on the date range

hi all, here is the description to my problem. input parameters: $date1 & $date2 based on the range i need to select the archived files from the archived directory and moved them in to working directory. can u please help me in writing the code to select the multiple files based on the... (3 Replies)
Discussion started by: bbc17484
3 Replies

6. Shell Programming and Scripting

mp3 tag/rename based on creation (last modified date)

Arg, I'm trying to figure out how to create a album tag based on the last modified date stamp for files which don't have a corresponding .talk file. IE. 2009 12 10 - Talk Radio.mp3 is how I want them structured, they should all have a corresponding .talk file so my mp3 player can speak the name ie... (0 Replies)
Discussion started by: mrplow
0 Replies

7. Shell Programming and Scripting

command to list files with path & date in a folder

Hi, I need command to display files with full path and date of files where are generated at every 5hrs in a folder. eg: /u01/app/test/orjthsd_1_1 Sun May 10 19:03:26 2009 /u01/app/test/weoiusd_1_1 Sun May 10 21:00:26 2009 thanks saha (3 Replies)
Discussion started by: saha
3 Replies

8. Shell Programming and Scripting

Creation of log file under dynamic date folder

HI I want to create a date folder and then a log file under it, which will hold all output of shell script. Say shell script abc.sh runs every day and I want to redirect the output of abc.sh > /opt/bea/wls81/Pkmtest/$(date +%Y%m%d)/ant.log. Here date should always change according to system... (2 Replies)
Discussion started by: pankajkrmishra
2 Replies

9. UNIX for Dummies Questions & Answers

Moving files based on creation date

Howdy, I'm trying to figure out how to move multiple files based on their creation date. If anyone can enlighten me it would be most appreciated!! Thanks! :D (1 Reply)
Discussion started by: dgoyea
1 Replies
Login or Register to Ask a Question