![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#8
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#9
|
||||
|
||||
|
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 |
|
#10
|
|||
|
|||
|
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 |
|
#11
|
||||
|
||||
|
ndoggy020,
Did you run the code I wrote above? Change the "ls" command from "ls -lt" to "ls -1t" and run it. |
|
#12
|
|||
|
|||
|
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?
|
|
#13
|
|||
|
|||
|
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
Thanks Nagarajan Ganesan |
|
#14
|
||||
|
||||
|
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 |
||||
| Google The UNIX and Linux Forums |
| Tags |
| mtime |
| Thread Tools | |
| Display Modes | |
|
|