![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| Processing a log file based on date/time input and the date/time on the log file | primp | Shell Programming and Scripting | 4 | 03-16-2008 11:23 AM |
| get Message from file within date range | ambharish | UNIX for Dummies Questions & Answers | 2 | 06-29-2007 05:20 PM |
| Log File date compare for user defined range | mojo24 | Shell Programming and Scripting | 0 | 05-05-2006 06:39 AM |
| date-extraction from a file in KSH | homer_hn | Shell Programming and Scripting | 6 | 04-21-2006 01:51 AM |
| Need to print file names in a certain date range using ls | Shamwari | UNIX for Dummies Questions & Answers | 2 | 10-08-2001 07:14 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
|||||
|
you can do something like this :
Code:
Start_Date='20060701'
End_Date='20060715'
Prefix='ramp_'
Suffix='.rpt'
ls ${Prefix}*${Suffix} 2>/dev/null |
while read file
do
datestamp=`echo ${file} | sed -e "s/^${Prefix}//; s/${Suffix}\$//"`
if [ $datestamp -ge ${Start_Date} -a ${datestamp} -le ${End_Date} ]
then
echo "Extract file $file"
else
echo "Ignore file $file"
fi
done
|
|
|||||
|
Thanks for your help aigles,
I found out a short way to do this from one of the resource. ls -lrt | awk '$9 ~ /20051001/ , $9 ~ /20060331/' | awk '{print $9}' Amazingly it is working fine for my requirement. I can able to find the files between the Start_Date and End_Date which is date stamped with the file names. Start_Date='20051001' End_Date='20060331' col1 col2 col3 col4 col5 col6 col7 col8 ramp_20050810.rpt col1 col2 col3 col4 col5 col6 col7 col8 ramp_20050819.rpt col1 col2 col3 col4 col5 col6 col7 col8 ramp_20050930.rpt col1 col2 col3 col4 col5 col6 col7 col8 ramp_20051001.rpt col1 col2 col3 col4 col5 col6 col7 col8 ramp_20051020.rpt col1 col2 col3 col4 col5 col6 col7 col8 ramp_20051119.rpt col1 col2 col3 col4 col5 col6 col7 col8 ramp_20051216.rpt col1 col2 col3 col4 col5 col6 col7 col8 ramp_20051219.rpt col1 col2 col3 col4 col5 col6 col7 col8 ramp_20060101.rpt col1 col2 col3 col4 col5 col6 col7 col8 ramp_20060230.rpt col1 col2 col3 col4 col5 col6 col7 col8 ramp_20060310.rpt col1 col2 col3 col4 col5 col6 col7 col8 ramp_20060420.rpt col1 col2 col3 col4 col5 col6 col7 col8 ramp_20060430.rpt above script extracting the filenames correctly as: ramp_20051001.rpt ramp_20051020.rpt ramp_20051119.rpt ramp_20051216.rpt ramp_20051219.rpt ramp_20060101.rpt ramp_20060230.rpt ramp_20060310.rpt Can any one explain this command that how it is able to select between these two date ranges !!!!!!???????My Sincere Thanks to all. Ganapati. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|