The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help Required: Command to find IP address and command executed of a user loggedout Security 2 08-06-2008 05:12 PM
how to? launch command with string of command line options TinCanFury Shell Programming and Scripting 5 04-28-2008 03:06 PM
inconsistent ls command display at the command prompt & running as a cron job rajranibl Linux 5 07-30-2007 05:26 AM
How to use more than one MPE command STREAM with Unix command in a single shell? bosskr HP-UX 1 10-16-2006 01:16 PM
How to use more than one MPE command STREAM with Unix command in a single shell? bosskr Shell Programming and Scripting 0 09-19-2006 06:44 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #8  
Old 04-12-2007
Registered User
 

Join Date: Apr 2007
Posts: 24
awk Thanks sooo much.

My mananger wants to know if their is any way feasible to search for a certain date, (i.e. March 22 2004)?

Or list all files between May 2, 2005 and June 3, 2006.

Stuff like that.

Let me know.

Thanks again awk
Reply With Quote
Forum Sponsor
  #9  
Old 04-12-2007
Shell_Life's Avatar
Registered User
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
The following commands display files between a certain date range:
Code:
## Creates a file with date of 01/Jan/2006 00:00
touch -m 0101000006 $$START_FILE

## Creates a file with date of 01/Jan/2007 00:00
touch -m 0101000007 $$END_FILE

## List files in date order and display only those in between
## $$START_FILE and $$END_FILE
ls -lt | sed -n "/$$END_FILE/,/$$START_FILE/p"

## Remove both temporary files.
rm -f $$START_FILE
rm -f $$END_FILE
Reply With Quote
  #10  
Old 04-12-2007
Registered User
 

Join Date: Apr 2007
Posts: 24
How would I now go about deleting those selected files from that certain date range?

Meaning I would like to delete all files from 2006.

Thanks again
Reply With Quote
  #11  
Old 04-12-2007
Shell_Life's Avatar
Registered User
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
ndoggy020,
Did you run the code I wrote above?
Change the "ls" command from "ls -lt" to "ls -1t" and run it.
Reply With Quote
  #12  
Old 04-12-2007
Registered User
 

Join Date: Apr 2007
Posts: 24
I did, and it indeed displayed the files within the date range I selected. Im just wondering what command I would use to delete those files?
Reply With Quote
  #13  
Old 04-12-2007
Registered User
 

Join Date: Mar 2007
Location: Chennai
Posts: 222
Listing File between two dates

As mentioned is the previous post,create to files with modification time as that of the date ranges

touch -mt 200505020000 /tmp/May-2-2005
touch -mt 200606030909 /tmp/June-6-2006

And try,
HTML Code:
find <your-dir> -name '*' \( -newer /tmp/May-2-2005 -a ! -newer /tmp/June-6-2006 \) -ls
Hope this helps.

Thanks
Nagarajan Ganesan
Reply With Quote
  #14  
Old 04-12-2007
Shell_Life's Avatar
Registered User
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Try this -- the "FINAL_rm_FILE" will have all the "rm" commands for each file:
Code:
ls -1t | sed -n "/$$END_FILE/,/$$START_FILE/p" > $$rm_FILE
sed 's/^/rm -f /' $$rm_FILE > FINAL_rm_FILE
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
mtime

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:15 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0