Quantcast
Channel: Make xargs execute the command once for each line of input - Stack Overflow
Viewing all articles
Browse latest Browse all 14

Make xargs execute the command once for each line of input

$
0
0

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 multiple lines to each instance.

From http://en.wikipedia.org/wiki/Xargs:

find /path -type f -print0 | xargs -0 rm

In this example, find feeds the input of xargs with a long list of file names. xargs then splits this list into sublists and calls rm once for every sublist. This is more efficient than this functionally equivalent version:

find /path -type f -exec rm '{}' \;

I know that find has the "exec" flag. I am just quoting an illustrative example from another resource.


Viewing all articles
Browse latest Browse all 14

Latest Images

Trending Articles





Latest Images