how to assign values in this date format
a=`date +"%H%M%S"`
how to give value of H=22,here in this format so that i can grep 22nd hour.Below is the script
--------------------------------------------------------------------------
a=`date +"%H%M%S"`
for i in *.log
do
cat $i | grep $a | wc -l >> file1.txt
done
-------------------------------------------------------------------------------
actually wat i m doing is greping Particular hour in all the logs files and storing the count in file1.txt
i want a date format that can be flexible enough to input our own hour values,depending upon my requirements.so i need that kind of a format to be used in my script.
Do you mean that you need only the hour field?
date +"%H"
Thanks
Nagarajan G
I'm guessing that you mean something like the following:
# date +"%H%M%S"
135756
# date +"22%M%S"
225759
# hour=23
# date +"${hour}%M%S"
235809
here is my script
------------------------------------------------------
TZ=`date +%Z`+24 ;a=`date +%Y-%m-%d`
b=`date +"23:%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
-------------------------------------------------------------------
As this script is outputing the result in Insert_Date.txt but the problem is that file Insert_Date.txt is empty. and i do have results in Acrhiver1.log
as
2008-02-03 23:10:59,345 [Thread-3] INFO -
2008-02-03 23:40:59,660 [Thread-3] INFO -
--------------------------------------------------------------------
not getting why file Insert_Date.txt is empty