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"`
------------------------------
HPAVC
February 12, 2008, 2:16am
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.
grep -E "20:[0-9][0-9]:[0-9][0-9]" ...
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
HPAVC
February 12, 2008, 5:34am
4
So this (very cut and paste, you could easily shorten)
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]" ...
vino
February 12, 2008, 5:40am
5
hpavc:
So this (very cut and paste, you could easily shorten)
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
grep -E "^[0-9]{4}-[0-9]{2}-[0-9]{2} 20:[0-9]{2}:[0-9]{2}" ...