Make xargs execute the command once for each line of input

后端 未结 13 660
栀梦
栀梦 2020-11-29 15:09

How can I make xargs execute the command exactly once for each line of input given? It\'s default behavior is to chunk the lines and execute the command once, passing multip

13条回答
  •  天命终不由人
    2020-11-29 15:25

    The following will only work if you do not have spaces in your input:

    xargs -L 1
    xargs --max-lines=1 # synonym for the -L option
    

    from the man page:

    -L max-lines
              Use at most max-lines nonblank input lines per command line.
              Trailing blanks cause an input line to be logically continued  on
              the next input line.  Implies -x.
    

提交回复
热议问题