The UNIX and Linux Forums  

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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Greping the required parameter... vijaya2006 Shell Programming and Scripting 3 04-01-2008 11:40 PM
greping date in a file ali560045 Shell Programming and Scripting 3 02-20-2008 04:30 AM
Greping certain lines csaha Shell Programming and Scripting 5 02-21-2006 12:43 AM
GREPing for Nulls Dr. DOT UNIX for Dummies Questions & Answers 4 09-17-2004 12:28 PM
Help with greping a field rooh UNIX for Dummies Questions & Answers 7 09-08-2003 09:42 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 02-11-2008
ali560045's Avatar
Registered User
 

Join Date: Oct 2007
Posts: 265
need help in greping

i have a ksh script :

#!/bin/ksh
TZ=`date +%Z`+24 ;a=`date +%Y-%m-%d`

b=`date +"%H:%M:%S"`
cd /ednadtu3/u01/pipe/logs
for i in Archiver1.log
do

cat $i | grep $a | grep $b >> /ednadtu3/u01/pipe/naveed/Insert_Date.txt
done
------------------------------------------------------------------

here i want to grep certain given values of hour in file Archiver1.log.
but this script greps current time of system. i want to grep 20th hour in file Archiver1.log. how to do that.

actually i want to insert the own values in below format

b=`date +"%H:%M:%S"`

------------------------------
Reply With Quote
Forum Sponsor
  #2  
Old 02-12-2008
HPAVC's Avatar
Registered User
 

Join Date: Feb 2008
Posts: 105
What does the data look like?

something like this what your looking for (obviously cleaned up to only match the date area of the log versus the content portion.

Code:
grep -E "20:[0-9][0-9]:[0-9][0-9]" ...
Reply With Quote
  #3  
Old 02-12-2008
ali560045's Avatar
Registered User
 

Join Date: Oct 2007
Posts: 265
the data looks like

2008-02-11 20:23:34
2008-02-11 20:53:20
2008-02-11 20:25:44


2008-02-11 21:40:34

2008-02-11 23:59:00

----------------------------------------------------------------------

i want to grep only 20th hour. thanks ur suggestion helped me. now i m able to grep . thanks dude

Last edited by ali560045; 02-12-2008 at 02:52 AM.
Reply With Quote
  #4  
Old 02-12-2008
HPAVC's Avatar
Registered User
 

Join Date: Feb 2008
Posts: 105
Quote:
Originally Posted by ali560045 View Post
2008-02-11 20:25:44

i want to grep only 20th hour. thanks ur suggestion helped me. now i m able to grep . thanks dude
So this (very cut and paste, you could easily shorten)

Code:
grep -E "^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] 20:[0-9][0-9]:[0-9][0-9]" ...
Reply With Quote
  #5  
Old 02-12-2008
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,699
Quote:
Originally Posted by HPAVC View Post
So this (very cut and paste, you could easily shorten)

Code:
grep -E "^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] 20:[0-9][0-9]:[0-9][0-9]" ...
Since you have the -E flag
Code:
grep -E "^[0-9]{4}-[0-9]{2}-[0-9]{2} 20:[0-9]{2}:[0-9]{2}" ...
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 06:34 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