LinuxQuestions.org

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

raj_deep2k1 01-21-2006 06: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 07:09 AM

so what problem are you having?

raj_deep2k1 01-21-2006 07: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 07: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 07: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 08: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 07:09 AM.