Wednesday, March 2, 2016

xargs argument replace argument redirection >

$ echo "foo" | xargs -IG echo G "bar"
> foo bar
or
deprecated form
$ echo "foo" | xargs -i echo {} "bar"
> foo bar



$ echo -e "one\ntwo\nthree" | xargs -I{} sh -c 'echo "$1" > "/tmp/file_$1.txt"' -- {}


Outros exemplos
$ ls -1 | xargs -I{} sh -c "grep ABC '{}' > '{}.out'"
find . -mindepth 1 -maxdepth 1 -type f -exec sh -c "grep ABC '{}' > '{}.out'" \;

No comments:

Blog Archive