5 ms·
cat hosts | xargs -I{} ssh root@{} hostname glad to know this one :-) echo y | xargs -Ix echo x how tricky!
by ryenus 11y ago
cat hosts | xargs -I{} ssh root@{} hostname
glad to know this one :-)
echo y | xargs -Ix echo x
how tricky!
- jnpatel 11y agoI agree, this is one of my favorite tricks. I like to think of xargs as a `map` function over stdin lines. As the article mentions, especially useful when combined with the -P flag for paralellism. cat urlpaths.txt | xargs -I{} -P wget domain.com/{} Another handy trick, is to use `sh -c` or `bash -c` to include multiple commands with xargs. cat dirs.txt | xargs -I{} sh -c 'cd {}; touch file;'