LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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, 06: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, 07:09 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
so what problem are you having?
 
Old 01-21-2006, 07: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, 07:18 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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, 07: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: 78
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 07:32 AM.
 
Old 01-21-2006, 08: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



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 10:17 AM
awk/sed help pantera Programming 1 05-13-2004 11:59 PM
using awk wedgeworth Linux - Newbie 9 02-20-2004 07:48 AM
awk problem jpostma Programming 7 10-22-2003 06:07 AM
lastlog date does not match system date? jcmj Linux - Networking 6 10-22-2002 12:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:55 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
Open Source Consulting | Domain Registration