The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to find min, max dates in a file gemini106 Shell Programming and Scripting 6 03-17-2008 01:55 AM
Help to switch dates from a file osramos Shell Programming and Scripting 2 11-15-2007 02:24 AM
Find number of days and list out the dates in between Raynon Shell Programming and Scripting 2 02-12-2007 08:52 PM
help searching log file with dates csaunders Shell Programming and Scripting 3 08-23-2005 12:50 PM
Formatting dates in a file maverick UNIX for Dummies Questions & Answers 6 12-18-2001 11:46 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-14-2008
justin_mca justin_mca is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 1
find log file between two dates

Dear All,

Please can you help me to crack this query?

If the log files for the task above all had a naming convention of myoutput_YearMonthDay.log (i.e. myoutput_20060215) How would you find only those log files created between the 10th and the 20th of each month going back the last 365 days.

Note: This script must run on a nightly basis and you cannot assume you know what year it is.

thanks in advance.
  #2 (permalink)  
Old 04-14-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Wink Here is an example of one approach

Code:
> ll s*
-rw-rw---- 1 jgillis dp 5 Apr 14 07:24 s20060210
-rw-rw---- 1 jgillis dp 5 Apr 14 07:25 s20060219
-rw-rw---- 1 jgillis dp 5 Apr 14 07:25 s20060220
-rw-rw---- 1 jgillis dp 5 Apr 14 07:25 s20060221
-rw-rw---- 1 jgillis dp 5 Apr 14 07:25 s20070219
-rw-rw---- 1 jgillis dp 5 Apr 14 07:25 s20070221

> ll s200???1? -o s200???20
-rw-rw---- 1 jgillis 5 Apr 14 07:24 s20060210
-rw-rw---- 1 jgillis 5 Apr 14 07:25 s20060219
-rw-rw---- 1 jgillis 5 Apr 14 07:25 s20060220
-rw-rw---- 1 jgillis 5 Apr 14 07:25 s20070219
Note that I only got files with dates 10-20 inclusive.

Code:
> ls -a s200???1? -o s200???20 | cut -d" " -f8
s20060210
s20060219
s20060220
s20070219
And now, just have the filenames.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:53 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0