LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices



Reply
 
Search this Thread
Old 01-21-2006, 07:57 AM   #1
raj_deep2k1
LQ Newbie
 
Registered: Jan 2006
Posts: 25

Rep: Reputation: 15
Question date in awk


hello i am facing problem in the following shell script.please help me.
file is as below

#Rwatch.sh
clear
tail -F /var/log/squid/access.log | awk '{print $3 "\t" date $7}' >> output.txt
 
Old 01-21-2006, 08:09 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
so what problem are you having?
 
Old 01-21-2006, 08:15 AM   #3
raj_deep2k1
LQ Newbie
 
Registered: Jan 2006
Posts: 25

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by acid_kewpie
so what problem are you having?
in the output.txt the date is not displaying.......

-Rajendra
 
Old 01-21-2006, 08:18 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
sample input text would be handy... can't test something without input, and i don't think too many people will have squid logs of their own...
 
Old 01-21-2006, 08:31 AM   #5
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 77
Code:
tail -F /var/log/squid/access.log | awk '{print $3 "\t" "date " $7}' >> output.txt
...will work if you are trying to print 'date' literally.

If you want 'the date' then try:
Code:
tail -F /var/log/squid/access.log | awk '{print $3 "\t" strftime() " " $7}' >> output.txt

Last edited by bulliver; 01-21-2006 at 08:32 AM.
 
Old 01-21-2006, 09:09 AM   #6
raj_deep2k1
LQ Newbie
 
Registered: Jan 2006
Posts: 25

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by bulliver
Code:
tail -F /var/log/squid/access.log | awk '{print $3 "\t" "date " $7}' >> output.txt
...will work if you are trying to print 'date' literally.

If you want 'the date' then try:
Code:
tail -F /var/log/squid/access.log | awk '{print $3 "\t" strftime() " " $7}' >> output.txt
thanks a lot

-Rajendra
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Start Date + Time Duration = End Date/Time calculator? ToBe Linux - General 3 09-26-2005 11:17 AM
awk/sed help pantera Programming 1 05-14-2004 12:59 AM
using awk wedgeworth Linux - Newbie 9 02-20-2004 08:48 AM
awk problem jpostma Programming 7 10-22-2003 07:07 AM
lastlog date does not match system date? jcmj Linux - Networking 6 10-22-2002 01:09 PM


All times are GMT -5. The time now is 02:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration