awk中使用shell命令
时间:2008-07-07 来源:foreman2002
一、使用system()
二、使用print cmd | “/bin/bash”
实例:
[root@MyVM log]# awk '{print "date +%s -d '\''",$1,$2,$3,"'\''"| "/bin/bash"}' test
1213089313
1213089323
1213089333
1213089343
1213089353
1213089363
[root@MyVM log]# cat test
Jun 10 17:15:13 MyVM kernel: BIOS-e820: 00000000 - 00000009f800 (usable)
Jun 10 17:15:23 MyVM kernel: BIOS-e820: 0009f800 - 0000000a0000 (reserved)
Jun 10 17:15:33 MyVM kernel: BIOS-e820: 000ca000 - 0000000cc000 (reserved)
Jun 10 17:15:43 MyVM kernel: BIOS-e820: 000dc000 - 000000100000 (reserved)
Jun 10 17:15:53 MyVM kernel: BIOS-e820: 00100000 - 00001fef0000 (usable)
Jun 10 17:16:03 MyVM kernel: BIOS-e820: 01fef000 - 00001feff000 (ACPI data)
二、使用print cmd | “/bin/bash”
实例:
[root@MyVM log]# awk '{print "date +%s -d '\''",$1,$2,$3,"'\''"| "/bin/bash"}' test
1213089313
1213089323
1213089333
1213089343
1213089353
1213089363
[root@MyVM log]# cat test
Jun 10 17:15:13 MyVM kernel: BIOS-e820: 00000000 - 00000009f800 (usable)
Jun 10 17:15:23 MyVM kernel: BIOS-e820: 0009f800 - 0000000a0000 (reserved)
Jun 10 17:15:33 MyVM kernel: BIOS-e820: 000ca000 - 0000000cc000 (reserved)
Jun 10 17:15:43 MyVM kernel: BIOS-e820: 000dc000 - 000000100000 (reserved)
Jun 10 17:15:53 MyVM kernel: BIOS-e820: 00100000 - 00001fef0000 (usable)
Jun 10 17:16:03 MyVM kernel: BIOS-e820: 01fef000 - 00001feff000 (ACPI data)
相关阅读 更多 +