1
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 1 year has passed since last update.

Argument list too longの対策まとめ

Last updated at Posted at 2023-04-05

前提

私は業務で2D画像の機械学習を触っています。学習データは時として数万枚になり、通常のlinuxコマンドでは表題のようなメッセージが出てくることがあります。

解決策

よく使う操作を一覧にしておく。

  • 現在いるディレクトリに存在する全てのファイルに対してchmodする。
find . -type f -exec chmod 777 {} \;
  • 現在いるディレクトリに存在する全てのjpgファイルを再帰的にrmする。
find . -name "*.jpg" -type f -print | xargs rm
  • 現在いるディレクトリに存在する全てのjpgファイルをcpする。
find . -name "*.png" -exec cp {} path/dir/to \;
  • 現在いるディレクトリ直下に存在する全てのpngファイルをカウントする。
find . -maxdepth 1 -name "*.png" | wc -l

-現在いるディレクトリ直下に存在する全てのテキストファイルの特定文字列を特定文字列に書き換える

grep -l 'mae' *
find . -type f | xargs sed -i 's/mae/ato/g'
1
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
1
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?