在awk中執行外部命令
1、借助system/getline刪除
awk '{cmd="rm "$0;system(cmd)}' filename
awk '{cmd="rm "$0;cmd|getline }' filename
man awk里面有關於getline的說明。
2、
awk '{system("wget -O - "url" | grep "ext" " | getline var) }' '{print var}'
system 函數外部命令調用所引用的參數兩邊必須使用雙引號包圍,否則引用無效。
command | getline [var]
Run command piping the output either into $0 or var, as above.
原文
[1]http://hi.baidu.com/crystalship/item/1abd3d1c8d3a0c426926bba7
[2]http://hi.baidu.com/asnahu/item/a4e862cffcb5fc14b67a2488