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
How to sort a field in a file having date values risshanth Shell Programming and Scripting 4 06-04-2008 02:03 AM
date issue-find prevoius date in a patricular format bsandeep_80 UNIX for Advanced & Expert Users 3 11-15-2007 04:42 PM
convert mmddyy date format to ccyyddd format?? Bhups Shell Programming and Scripting 2 09-27-2006 08:30 PM
Inserting Values From A File Into A Table ragha81 Shell Programming and Scripting 2 09-16-2006 04:10 PM
Inserting Date&Time Stamp In Existing Log File shephardfamily UNIX for Dummies Questions & Answers 3 02-24-2006 12:01 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-01-2008
ali560045's Avatar
Registered User
 

Join Date: Oct 2007
Posts: 219
help in inserting values in date format

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.

Last edited by ali560045; 02-01-2008 at 05:29 AM.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-01-2008
Registered User
 

Join Date: Mar 2007
Location: Chennai
Posts: 222
Do you mean that you need only the hour field?

Code:
date +"%H"
Thanks
Nagarajan G
Reply With Quote
  #3 (permalink)  
Old 02-01-2008
Tytalus's Avatar
Registered User
 

Join Date: Jun 2003
Location: Scotland
Posts: 249
I'm guessing that you mean something like the following:

Code:
#  date +"%H%M%S"
135756

#  date +"22%M%S"
225759

#  hour=23
#  date +"${hour}%M%S"
235809

Last edited by Tytalus; 02-01-2008 at 05:59 AM. Reason: minor typo
Reply With Quote
  #4 (permalink)  
Old 02-04-2008
ali560045's Avatar
Registered User
 

Join Date: Oct 2007
Posts: 219
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

Last edited by ali560045; 02-05-2008 at 01:55 AM.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:30 PM.


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 Global Fact Book

Content Relevant URLs by vBSEO 3.2.0