![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
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"` ------------------------------ |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
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]" ... |
|
#3
|
||||
|
||||
|
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. |
|
#4
|
||||
|
||||
|
Quote:
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]" ... |
|
#5
|
||||
|
||||
|
Quote:
Code:
grep -E "^[0-9]{4}-[0-9]{2}-[0-9]{2} 20:[0-9]{2}:[0-9]{2}" ...
|
||||
| Google The UNIX and Linux Forums |