The documentation only states vaguely what it does in words, and I can't find any examples readily on the internet.
So, how can I use the -I flag of xargs? I know it has something to do with string substitution in the argument command, but its not clear how to use it.
From tldr xargs
:
- Execute the command once for each input line, replacing any occurrences of the placeholder (here marked as `_`) with the input line:
arguments_source | xargs -I _ command _ optional_extra_arguments
so, something like this:
$ echo "foo" | xargs -I _ echo "bar-"_
bar-foo
xargs
takes the input foo
, replaces the _
with it and instead of printing bar-_
prints bar-foo
to console