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
modifying grep to return latest files ragha81 Shell Programming and Scripting 5 04-02-2009 11:16 AM
how to grep word from .gz files & .z files udaya_subbu Shell Programming and Scripting 8 08-08-2008 05:53 AM
modifying C file and linking back to project files bruins2005 UNIX for Dummies Questions & Answers 1 06-22-2006 11:08 PM
Perl - Appending/Modifying Excel files srinivay Shell Programming and Scripting 2 01-10-2005 06:46 AM
How can I ... (Modifying large ASCII files) hviktor UNIX for Dummies Questions & Answers 2 07-20-2001 10:28 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 01-11-2007
ragha81 ragha81 is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 145
modifying grep to get files only within last 2 hrs

Hi gurus

I am currently using the below mentioned grep to find timestamp of last generated log file.

Code:
 touch  -t $time_search dummy
       ecust_time_stamp=$(find .  -name 'eCustomerCME*' -newer dummy  -type f  -exec ls -ltr {} \; | tail -1 | awk ' { print $6,$7,$8 } ')
I calculate dummy variable based on this script

Code:
export day=`date +%d`
export month=`date +%m`
export day_len=${#day}
export mon_len=${#month}
export hr_min=0000
if [[ $day_len -lt 2 ]] || [[ $mon_len -lt 2 ]] 
then
   month=0$month
   day=0$day   
   export time_search=$month$day$hr_min
else 
   export time_search=$month$day$hr_min
fi
i need to modify my grep to search for log files generated only in last 2 hrs. can anyone suggest on how to do that.

thanks in advance
  #2 (permalink)  
Old 01-11-2007
becket's Avatar
becket becket is offline
Registered User
  
 

Join Date: Jul 2005
Location: Liege / Belgium
Posts: 36
Try
Code:
-not -newer
  #3 (permalink)  
Old 01-11-2007
ragha81 ragha81 is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 145
hi

thanks for the reply. which part of my code should i include that in.
  #4 (permalink)  
Old 01-11-2007
becket's Avatar
becket becket is offline
Registered User
  
 

Join Date: Jul 2005
Location: Liege / Belgium
Posts: 36
within the find

find blablabla ... -not -newer blablabla
Sponsored Links
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 05:02 PM.


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