0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

複数フォルダ内のファイルをシェルスクリプトで並列実行する

Posted at

任意のフォルダ内の全てのファイルに対してコマンドを実行したいときに使う

find [指定のフォルダまでのパス]/* -type d | xargs  -L 1 -P [並列数] sh -c 'cd "$0" && [コマンド] `

├─ parent
 │
 ├──child1
 | └─test1
 ├──child2
 | └─test2
 ├──child3
 | └─test3

上記のような構造の場合いかのような結果となる

$ find parent/* -type d | xargs  -L 1 -P 3 sh -c 'cd "$0" && ls'
$ test1test2test3
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?