Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding Time Zone to Log File 1

Status
Not open for further replies.

faelord

Technical User
Jan 4, 2002
6
GB
Our log files are in the format

May 18 10:37:56 faelord ftpd[10062]: FTP LOGIN REFUSED (access denied) FROM ...
May 18 10:03:50 faelord in.rshd[8691]: connect from ...

We need to send them to someone who has requested the timezone be included ie

May 18 10:37:56 CST faelord ftpd[10062]: FTP LOGIN REFUSED (access denied) FROM
May 18 10:03:50 CST faelord in.rshd[8691]: connect from

Has anyone got a simple shell script that could be run to add the CST in the appropriate place
regardless of month?

Thanks
 
Can you just add an `echo $TZ` in the appropriate place. If not, can you post an extract of the script where the filename is constructed? Note that the ` above are 'backticks' (ie above the tab key), not normal apostrophes. HTH.
 
Maybe this (untested) awk script will do what you want.
Code:
{
   for (i=1;i<=3;i++) printf $i &quot; &quot;
   printf &quot;CST&quot;
   for (i=4;i<=NF;i++) printf &quot; &quot; $i
   print &quot;&quot;
}
Hope this helps. CaKiwi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top