Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Awk > Re: awk 'system...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 6 of 12 Topic 2171 of 2236
Post > Topic >>

Re: awk 'system("date +%s -d ")'

by Ed Morton <morton@[EMAIL PROTECTED] > Feb 24, 2008 at 05:04 PM

On 2/24/2008 4:36 PM, DanielC wrote:
>>>$ echo "[2008-02-24 21:07:08.149124] 6451642 196612 547 0 6839170" |
awk 
>>>'{print gensub(/\[(....)-(..)-(..) (..):(..):(..).*/,"\\1 \\2 \\3 \\4
\\5 
>>>\\6","")}'
>>>2008 02 24 21 07 08
>>
> 
> This is great! I don't know gensub() can do that.
> 
> 
>>>However, # awk -F "[].[]+" 'system("date +%s -d " $2)' /tmp/logfile 
>>>doesn't.
>>>
>>
>>Doesn't what? What do you want the output to be?
> 
> 
> I want # awk -F "[].[]+" 'system("date +%s -d " $2)' /tmp/logfile 
output 
> the timestamp like $ awk 'BEGIN {system("date +%s -d " "\"2008-02-24 
> 09:14:03\"")}' does. However it doesn't.
> 
> # echo "[2008-02-24 21:07:08.149124] 6451642 196612 547 0 6839170" | awk
-F 
> "[].[]+" 'system("date +%s -d ") $2'
> date: option requires an argument -- d
> Try `date --help' for more information.
> [2008-02-24 21:07:08.149124] 6451642 196612 547 0 6839170

This seems to be what you're asking for:

$ echo "[2008-02-24 21:07:08.149124] 6451642 196612 547 0 6839170" |
awk -F "[].[]+" 'system("date +%s -d \"" $2 "\"")'
1203908828

but I'm sure there's a better way to do whatever it is you're trying to do
just
using awk instead of jumping back and forth between awk and shell
commands. If
you can show us some sample input and expected out, I expect we could
help.

	Ed.




 12 Posts in Topic:
awk 'system("date +%s -d ")'
"DanielC" <d  2008-02-24 13:06:04 
Re: awk 'system("date +%s -d ")'
Ed Morton <morton@[EMA  2008-02-24 15:23:36 
Re: awk 'system("date +%s -d ")'
"DanielC" <d  2008-02-24 13:50:28 
Re: awk 'system("date +%s -d ")'
Ed Morton <morton@[EMA  2008-02-24 15:56:40 
Re: awk 'system("date +%s -d ")'
"DanielC" <d  2008-02-24 14:36:52 
Re: awk 'system("date +%s -d ")'
Ed Morton <morton@[EMA  2008-02-24 17:04:05 
Re: awk 'system("date +%s -d ")'
"DanielC" <d  2008-02-24 15:34:58 
Re: awk 'system("date +%s -d ")'
Ed Morton <morton@[EMA  2008-02-24 23:21:07 
Re: awk 'system("date +%s -d ")'
"DanielC" <d  2008-02-26 23:29:11 
Re: awk 'system("date +%s -d ")'
Janis <janis_papanagno  2008-02-27 00:56:02 
Re: awk 'system("date +%s -d ")'
dnlchen@[EMAIL PROTECTED]  2008-02-29 18:04:36 
Re: awk 'system("date +%s -d ")'
mik3l3374@[EMAIL PROTECTE  2008-02-25 01:07:27 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri May 16 11:29:43 CDT 2008.