How can I pass variables from awk to a shell command?

前端 未结 5 1734
太阳男子
太阳男子 2020-12-01 04:14

I am trying to run a shell command from within awk for each line of a file, and the shell command needs one input argument. I tried to use system(), but it didn

5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-01 05:04

    I would suggest another solution:

    awk '{print $1}' myfile | xargs wc
    

    the difference is that it executes wc once with multiple arguments. It often works (for example, with kill command)

提交回复
热议问题