LoginSignup
61
53

More than 5 years have passed since last update.

xargsで複数コマンドを実行する

Last updated at Posted at 2015-02-14

-Iオプションで実行コマンドの特定の文字を標準入力の値に置換できるので、それとshを組み合わせる

$ ls
a.txt  b.txt
$ ls | xargs -I{} sh -c 'echo {}; echo {}'
a.txt
a.txt
b.txt
b.txt

-Iオプションは環境によっては--replaceであったりするのでmanで確認する。

61
53
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
61
53