LoginSignup
3
3

More than 5 years have passed since last update.

たくさんのファイルを削除する

Posted at

たくさんファイルを作りたくて

create_files
$ for i in {000001..900000} ; do ;
echo "hello" > "test${i}.txt"
; done

を実行した。間違ってホームディレクトリで実行してしまったのでディレクトリごと消すわけにもいかず、

rm_0
$ rm *.txt
zsh: 引数リストが長すぎます: rm

だし、

rm_1
$ for i in {000001..900000} ; do ;
rm "test${i}.txt"
; done

も一時間くらい経っても処理が始まらない。

rm_2
$ find . -maxdepth 1 -name "test*.txt"  | xargs rm

で削除することができた。処理時間もすごく短かった。

3
3
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
3
3