先把文件列表存在filename文件中
先
awk '{system("rm $0")}' filename -------WRONG
因为对于 system来说 $0 不再是某行全部的内容,而是 “sh” , 上面的命令相当于执行“ sh rm sh”
然后
awk '{cmd="rm "$0;system(cmd)}' filename ----OK
下面的也ok
awk '{cmd="rm "$0;cmd|getline }' filename ---- OK
man awk里面关于getline的说明,大意是说 运行command,同时会把输出存在$0 里面,或参数var中。
command | getline [var]
Run command piping the output either into $0 or var, as above.
command |& getline [var]
Run command as a co-process piping the output either into $0 or var, as above.
Co-processes are a gawk extension.