LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   date in awk (http://www.linuxquestions.org/questions/linux-networking-3/date-in-awk-406123/)

raj_deep2k1 01-21-2006 07:57 AM

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

acid_kewpie 01-21-2006 08:09 AM

so what problem are you having?

raj_deep2k1 01-21-2006 08:15 AM

Quote:

Originally Posted by acid_kewpie
so what problem are you having?

in the output.txt the date is not displaying.......

-Rajendra

acid_kewpie 01-21-2006 08:18 AM

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...

bulliver 01-21-2006 08:31 AM

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

raj_deep2k1 01-21-2006 09:09 AM

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


All times are GMT -5. The time now is 05:50 PM.