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.

findコマンドで検索したファイルを削除する方法の速度を比較してみた

Posted at

結論

-exec rm -f {} + -delete xargs rm -f はほぼ同じ速度なので状況に応じて使い分けるとよさそう。

-exec rm -f {} \; は他3つと比べて大きく劣るので特別な理由がない限り使わないほうがいい。

※deleteオプションは環境によっては使えない場合があるらしい。1

※xargsはファイルにスペースなど特殊な文字列が含まれていると削除できないため、別途対応が必要。2

検証環境

マシン: Raspberry Pi 4 Model B(メモリ4GB)

OS: Debian 11

検証するコマンド

  1. find -exec rm -f {} \;
  2. find -exec rm -f {} +
  3. find -delete
  4. find | xargs rm -f

検証方法

削除対象ディレクトリに2万ファイル(うち削除対象1万ファイル)を用意し、findコマンドで検索、削除を行う。

処理時間の計測はtimeコマンドを用いる。

一つのコマンドに対し100回計測を行い、平均値で比較する。

検証用プログラム

#!/bin/bash

# 削除対象ディレクトリ
REMOVE_TARGET_DIR="./target"

# 空ファイル作成
touchFile(){
  touch $REMOVE_TARGET_DIR/{1..10000}
  touch $REMOVE_TARGET_DIR/{1..10000}.log
}

# 100回やる
for i in {1..100};
do
  # 検証1
  # -exec rm -f {} \;
  touchFile
  (time find $REMOVE_TARGET_DIR -name "*.log" -type f -exec rm -f {} \;) > "exec_slow_$i.log" 2>&1

  # 検証2
  # -exec rm -f {} +
  touchFile
  (time find $REMOVE_TARGET_DIR -name "*.log" -type f -exec rm -f {} +) > "exec_fast_$i.log" 2>&1


  # 検証3
  # -delete
  touchFile
  (time find $REMOVE_TARGET_DIR -name "*.log" -type f -delete) > "option_$i.log" 2>&1

  # 検証4
  # xargs rm -f
  touchFile
  (time find $REMOVE_TARGET_DIR -name "*.log" -type f | xargs rm -f) > "xargs_$i.log" 2>&1
done

結果

単位: 秒

-exec rm -f {} \ -exec rm -f {} + -delete xargs rm -f
real 39.51399 0.50603 0.42257 0.50897
user 9.86015 0.07339 0.05953 0.0757
sys 29.3712 0.41425 0.34913 0.42295
それぞれの実行結果(とても長いので注意)

-exec rm -f {} \;

回数 real user sys
1 0m39.387s 0m9.746s 0m29.640s
2 0m39.129s 0m9.999s 0m28.912s
3 0m40.165s 0m9.841s 0m29.946s
4 0m39.699s 0m9.860s 0m29.443s
5 0m39.754s 0m9.950s 0m29.538s
6 0m39.874s 0m9.686s 0m29.850s
7 0m39.843s 0m9.636s 0m29.814s
8 0m39.381s 0m9.602s 0m29.705s
9 0m39.829s 0m9.644s 0m29.740s
10 0m39.318s 0m9.960s 0m28.961s
11 0m39.533s 0m9.816s 0m29.435s
12 0m40.095s 0m9.789s 0m29.982s
13 0m39.504s 0m9.946s 0m29.187s
14 0m39.766s 0m9.751s 0m29.990s
15 0m39.229s 0m10.087s 0m28.893s
16 0m39.947s 0m9.882s 0m29.745s
17 0m40.008s 0m9.723s 0m29.871s
18 0m39.394s 0m9.623s 0m29.682s
19 0m39.625s 0m9.983s 0m29.336s
20 0m39.560s 0m9.801s 0m29.543s
21 0m39.268s 0m9.934s 0m29.173s
22 0m39.614s 0m9.770s 0m29.577s
23 0m39.294s 0m10.073s 0m28.986s
24 0m39.285s 0m9.835s 0m29.222s
25 0m39.601s 0m9.885s 0m29.467s
26 0m39.411s 0m9.773s 0m29.523s
27 0m39.410s 0m9.815s 0m29.197s
28 0m39.430s 0m9.890s 0m29.299s
29 0m39.664s 0m9.849s 0m29.408s
30 0m39.415s 0m9.879s 0m29.178s
31 0m39.334s 0m9.919s 0m29.188s
32 0m39.458s 0m9.750s 0m29.370s
33 0m39.963s 0m9.719s 0m29.880s
34 0m39.488s 0m9.956s 0m29.209s
35 0m39.193s 0m9.871s 0m29.032s
36 0m39.794s 0m10.037s 0m29.152s
37 0m39.103s 0m9.954s 0m29.034s
38 0m39.223s 0m9.721s 0m29.338s
39 0m39.806s 0m10.043s 0m29.170s
40 0m39.288s 0m10.170s 0m28.729s
41 0m39.093s 0m9.779s 0m28.953s
42 0m39.832s 0m9.788s 0m29.635s
43 0m39.501s 0m9.765s 0m29.497s
44 0m39.576s 0m10.009s 0m29.151s
45 0m39.636s 0m9.974s 0m29.305s
46 0m39.805s 0m9.823s 0m29.485s
47 0m39.441s 0m9.574s 0m29.619s
48 0m39.488s 0m9.914s 0m29.296s
49 0m38.901s 0m9.921s 0m28.880s
50 0m39.426s 0m9.694s 0m29.479s
51 0m38.967s 0m10.049s 0m28.722s
52 0m39.458s 0m9.722s 0m29.616s
53 0m39.656s 0m9.592s 0m29.783s
54 0m39.437s 0m9.958s 0m29.306s
55 0m39.552s 0m9.859s 0m29.453s
56 0m39.584s 0m9.923s 0m29.311s
57 0m39.575s 0m9.804s 0m29.632s
58 0m39.200s 0m9.895s 0m29.116s
59 0m39.597s 0m9.860s 0m29.492s
60 0m39.838s 0m9.660s 0m29.780s
61 0m39.147s 0m9.857s 0m29.063s
62 0m39.400s 0m9.766s 0m29.356s
63 0m39.556s 0m9.850s 0m29.383s
64 0m39.236s 0m9.902s 0m29.170s
65 0m39.348s 0m9.917s 0m29.098s
66 0m39.341s 0m9.734s 0m29.392s
67 0m39.654s 0m9.757s 0m29.565s
68 0m39.413s 0m9.937s 0m29.182s
69 0m39.608s 0m9.858s 0m29.326s
70 0m39.591s 0m9.759s 0m29.439s
71 0m39.617s 0m9.868s 0m29.470s
72 0m39.835s 0m9.690s 0m29.717s
73 0m39.618s 0m9.999s 0m29.448s
74 0m39.472s 0m10.301s 0m28.939s
75 0m38.899s 0m10.071s 0m28.857s
76 0m39.271s 0m9.762s 0m29.159s
77 0m39.655s 0m9.768s 0m29.504s
78 0m39.614s 0m9.756s 0m29.579s
79 0m39.699s 0m9.805s 0m29.543s
80 0m39.635s 0m9.673s 0m29.707s
81 0m39.443s 0m10.089s 0m29.050s
82 0m39.566s 0m9.846s 0m29.307s
83 0m39.899s 0m9.796s 0m29.833s
84 0m39.499s 0m9.979s 0m29.286s
85 0m39.329s 0m9.944s 0m29.269s
86 0m39.757s 0m9.759s 0m29.538s
87 0m39.108s 0m10.045s 0m28.745s
88 0m39.149s 0m9.958s 0m29.081s
89 0m39.380s 0m9.942s 0m29.121s
90 0m39.175s 0m9.870s 0m28.968s
91 0m39.416s 0m10.138s 0m29.011s
92 0m39.304s 0m9.870s 0m29.238s
93 0m39.426s 0m9.818s 0m29.547s
94 0m39.538s 0m9.823s 0m29.352s
95 0m39.976s 0m9.866s 0m29.724s
96 0m39.732s 0m9.747s 0m29.653s
97 0m39.495s 0m9.995s 0m29.480s
98 0m39.631s 0m9.977s 0m29.423s
99 0m39.243s 0m9.881s 0m29.025s
100 0m40.079s 0m9.911s 0m29.716s

-exec rm -f {} +

回数 real user sys
1 0m0.492s 0m0.085s 0m0.404s
2 0m0.495s 0m0.063s 0m0.426s
3 0m0.492s 0m0.094s 0m0.394s
4 0m0.488s 0m0.067s 0m0.416s
5 0m0.492s 0m0.068s 0m0.418s
6 0m0.493s 0m0.060s 0m0.428s
7 0m0.495s 0m0.069s 0m0.421s
8 0m0.494s 0m0.091s 0m0.397s
9 0m0.487s 0m0.073s 0m0.410s
10 0m0.493s 0m0.084s 0m0.404s
11 0m0.492s 0m0.057s 0m0.429s
12 0m0.499s 0m0.063s 0m0.430s
13 0m0.494s 0m0.085s 0m0.404s
14 0m0.493s 0m0.078s 0m0.409s
15 0m0.496s 0m0.063s 0m0.428s
16 0m0.485s 0m0.075s 0m0.403s
17 0m0.544s 0m0.093s 0m0.406s
18 0m0.487s 0m0.085s 0m0.395s
19 0m0.491s 0m0.093s 0m0.394s
20 0m0.699s 0m0.064s 0m0.435s
21 0m0.493s 0m0.086s 0m0.402s
22 0m0.495s 0m0.056s 0m0.434s
23 0m0.491s 0m0.082s 0m0.404s
24 0m0.488s 0m0.079s 0m0.405s
25 0m0.494s 0m0.072s 0m0.418s
26 0m0.487s 0m0.081s 0m0.399s
27 0m0.491s 0m0.068s 0m0.418s
28 0m0.490s 0m0.052s 0m0.433s
29 0m0.494s 0m0.070s 0m0.418s
30 0m0.486s 0m0.056s 0m0.426s
31 0m0.497s 0m0.082s 0m0.408s
32 0m0.491s 0m0.074s 0m0.413s
33 0m0.492s 0m0.059s 0m0.429s
34 0m0.498s 0m0.085s 0m0.406s
35 0m0.485s 0m0.066s 0m0.414s
36 0m0.495s 0m0.089s 0m0.399s
37 0m0.489s 0m0.070s 0m0.413s
38 0m0.493s 0m0.071s 0m0.415s
39 0m0.488s 0m0.075s 0m0.405s
40 0m0.492s 0m0.072s 0m0.414s
41 0m0.494s 0m0.095s 0m0.393s
42 0m0.492s 0m0.076s 0m0.412s
43 0m0.486s 0m0.076s 0m0.406s
44 0m0.496s 0m0.083s 0m0.406s
45 0m0.487s 0m0.064s 0m0.416s
46 0m0.493s 0m0.068s 0m0.419s
47 0m0.494s 0m0.071s 0m0.418s
48 0m0.495s 0m0.089s 0m0.401s
49 0m0.488s 0m0.086s 0m0.398s
50 0m0.488s 0m0.087s 0m0.396s
51 0m0.746s 0m0.056s 0m0.432s
52 0m0.487s 0m0.068s 0m0.415s
53 0m0.493s 0m0.069s 0m0.419s
54 0m0.495s 0m0.098s 0m0.392s
55 0m0.488s 0m0.072s 0m0.411s
56 0m0.487s 0m0.052s 0m0.430s
57 0m0.503s 0m0.075s 0m0.423s
58 0m0.488s 0m0.080s 0m0.404s
59 0m0.492s 0m0.056s 0m0.431s
60 0m0.739s 0m0.079s 0m0.423s
61 0m0.489s 0m0.078s 0m0.407s
62 0m0.489s 0m0.091s 0m0.393s
63 0m0.709s 0m0.059s 0m0.432s
64 0m0.492s 0m0.082s 0m0.404s
65 0m0.491s 0m0.089s 0m0.397s
66 0m0.489s 0m0.079s 0m0.405s
67 0m0.488s 0m0.061s 0m0.420s
68 0m0.486s 0m0.066s 0m0.414s
69 0m0.487s 0m0.073s 0m0.409s
70 0m0.501s 0m0.059s 0m0.436s
71 0m0.494s 0m0.077s 0m0.411s
72 0m0.487s 0m0.063s 0m0.418s
73 0m0.493s 0m0.071s 0m0.417s
74 0m0.769s 0m0.084s 0m0.457s
75 0m0.489s 0m0.066s 0m0.417s
76 0m0.490s 0m0.068s 0m0.418s
77 0m0.495s 0m0.076s 0m0.413s
78 0m0.489s 0m0.075s 0m0.409s
79 0m0.492s 0m0.064s 0m0.422s
80 0m0.489s 0m0.067s 0m0.415s
81 0m0.489s 0m0.066s 0m0.419s
82 0m0.490s 0m0.069s 0m0.416s
83 0m0.495s 0m0.071s 0m0.418s
84 0m0.491s 0m0.061s 0m0.425s
85 0m0.498s 0m0.095s 0m0.398s
86 0m0.493s 0m0.085s 0m0.403s
87 0m0.579s 0m0.096s 0m0.422s
88 0m0.495s 0m0.082s 0m0.409s
89 0m0.488s 0m0.072s 0m0.411s
90 0m0.492s 0m0.064s 0m0.423s
91 0m0.494s 0m0.056s 0m0.433s
92 0m0.495s 0m0.089s 0m0.401s
93 0m0.489s 0m0.069s 0m0.415s
94 0m0.491s 0m0.087s 0m0.398s
95 0m0.487s 0m0.046s 0m0.435s
96 0m0.598s 0m0.070s 0m0.427s
97 0m0.491s 0m0.062s 0m0.423s
98 0m0.490s 0m0.060s 0m0.426s
99 0m0.496s 0m0.052s 0m0.438s
100 0m0.493s 0m0.084s 0m0.402s

-delete

回数 real user sys
1 0m0.417s 0m0.071s 0m0.341s
2 0m0.413s 0m0.051s 0m0.357s
3 0m0.417s 0m0.071s 0m0.341s
4 0m0.417s 0m0.048s 0m0.363s
5 0m0.631s 0m0.063s 0m0.357s
6 0m0.415s 0m0.063s 0m0.346s
7 0m0.411s 0m0.080s 0m0.326s
8 0m0.411s 0m0.052s 0m0.353s
9 0m0.410s 0m0.048s 0m0.356s
10 0m0.415s 0m0.067s 0m0.342s
11 0m0.410s 0m0.072s 0m0.331s
12 0m0.412s 0m0.080s 0m0.327s
13 0m0.410s 0m0.040s 0m0.363s
14 0m0.416s 0m0.052s 0m0.358s
15 0m0.413s 0m0.064s 0m0.343s
16 0m0.414s 0m0.079s 0m0.329s
17 0m0.414s 0m0.040s 0m0.367s
18 0m0.411s 0m0.048s 0m0.358s
19 0m0.529s 0m0.064s 0m0.367s
20 0m0.412s 0m0.072s 0m0.335s
21 0m0.416s 0m0.047s 0m0.364s
22 0m0.413s 0m0.067s 0m0.340s
23 0m0.413s 0m0.055s 0m0.352s
24 0m0.414s 0m0.052s 0m0.356s
25 0m0.416s 0m0.045s 0m0.366s
26 0m0.416s 0m0.072s 0m0.338s
27 0m0.417s 0m0.068s 0m0.343s
28 0m0.414s 0m0.060s 0m0.349s
29 0m0.409s 0m0.048s 0m0.355s
30 0m0.412s 0m0.036s 0m0.371s
31 0m0.411s 0m0.068s 0m0.337s
32 0m0.414s 0m0.059s 0m0.348s
33 0m0.415s 0m0.075s 0m0.333s
34 0m0.416s 0m0.068s 0m0.343s
35 0m0.417s 0m0.068s 0m0.343s
36 0m0.411s 0m0.031s 0m0.374s
37 0m0.412s 0m0.044s 0m0.362s
38 0m0.410s 0m0.048s 0m0.355s
39 0m0.416s 0m0.048s 0m0.362s
40 0m0.415s 0m0.044s 0m0.364s
41 0m0.412s 0m0.044s 0m0.361s
42 0m0.414s 0m0.079s 0m0.329s
43 0m0.412s 0m0.060s 0m0.346s
44 0m0.413s 0m0.051s 0m0.356s
45 0m0.415s 0m0.088s 0m0.323s
46 0m0.410s 0m0.048s 0m0.356s
47 0m0.414s 0m0.064s 0m0.345s
48 0m0.413s 0m0.052s 0m0.355s
49 0m0.411s 0m0.056s 0m0.350s
50 0m0.418s 0m0.060s 0m0.352s
51 0m0.418s 0m0.056s 0m0.357s
52 0m0.412s 0m0.059s 0m0.347s
53 0m0.413s 0m0.092s 0m0.316s
54 0m0.409s 0m0.056s 0m0.347s
55 0m0.411s 0m0.072s 0m0.333s
56 0m0.414s 0m0.068s 0m0.340s
57 0m0.416s 0m0.051s 0m0.359s
58 0m0.417s 0m0.035s 0m0.376s
59 0m0.416s 0m0.044s 0m0.367s
60 0m0.411s 0m0.052s 0m0.354s
61 0m0.417s 0m0.048s 0m0.363s
62 0m0.501s 0m0.075s 0m0.348s
63 0m0.414s 0m0.068s 0m0.340s
64 0m0.412s 0m0.061s 0m0.346s
65 0m0.416s 0m0.072s 0m0.339s
66 0m0.411s 0m0.048s 0m0.358s
67 0m0.411s 0m0.052s 0m0.353s
68 0m0.411s 0m0.122s 0m0.282s
69 0m0.415s 0m0.067s 0m0.342s
70 0m0.414s 0m0.079s 0m0.330s
71 0m0.409s 0m0.064s 0m0.340s
72 0m0.412s 0m0.056s 0m0.350s
73 0m0.446s 0m0.051s 0m0.369s
74 0m0.412s 0m0.064s 0m0.343s
75 0m0.412s 0m0.076s 0m0.331s
76 0m0.413s 0m0.056s 0m0.352s
77 0m0.413s 0m0.059s 0m0.348s
78 0m0.412s 0m0.044s 0m0.363s
79 0m0.412s 0m0.072s 0m0.334s
80 0m0.410s 0m0.060s 0m0.344s
81 0m0.410s 0m0.064s 0m0.341s
82 0m0.414s 0m0.055s 0m0.353s
83 0m0.417s 0m0.052s 0m0.359s
84 0m0.587s 0m0.052s 0m0.369s
85 0m0.414s 0m0.048s 0m0.360s
86 0m0.414s 0m0.068s 0m0.339s
87 0m0.410s 0m0.059s 0m0.345s
88 0m0.413s 0m0.064s 0m0.342s
89 0m0.597s 0m0.059s 0m0.360s
90 0m0.411s 0m0.078s 0m0.327s
91 0m0.415s 0m0.079s 0m0.330s
92 0m0.416s 0m0.068s 0m0.343s
93 0m0.415s 0m0.048s 0m0.361s
94 0m0.413s 0m0.052s 0m0.355s
95 0m0.526s 0m0.036s 0m0.393s
96 0m0.413s 0m0.044s 0m0.363s
97 0m0.412s 0m0.055s 0m0.351s
98 0m0.413s 0m0.039s 0m0.368s
99 0m0.416s 0m0.064s 0m0.347s
100 0m0.414s 0m0.060s 0m0.348s

xargs rm -f

回数 real user sys
1 0m0.482s 0m0.066s 0m0.428s
2 0m0.485s 0m0.073s 0m0.424s
3 0m0.480s 0m0.085s 0m0.406s
4 0m0.650s 0m0.077s 0m0.444s
5 0m0.483s 0m0.071s 0m0.422s
6 0m0.482s 0m0.095s 0m0.398s
7 0m0.489s 0m0.069s 0m0.431s
8 0m0.485s 0m0.076s 0m0.420s
9 0m0.481s 0m0.086s 0m0.407s
10 0m0.484s 0m0.088s 0m0.407s
11 0m0.482s 0m0.064s 0m0.430s
12 0m0.486s 0m0.074s 0m0.423s
13 0m0.484s 0m0.074s 0m0.420s
14 0m0.481s 0m0.084s 0m0.409s
15 0m0.488s 0m0.070s 0m0.429s
16 0m0.487s 0m0.102s 0m0.395s
17 0m0.487s 0m0.075s 0m0.424s
18 0m0.548s 0m0.063s 0m0.457s
19 0m0.485s 0m0.069s 0m0.428s
20 0m0.486s 0m0.076s 0m0.421s
21 0m0.486s 0m0.069s 0m0.429s
22 0m0.480s 0m0.067s 0m0.424s
23 0m0.489s 0m0.102s 0m0.399s
24 0m0.487s 0m0.083s 0m0.414s
25 0m0.484s 0m0.068s 0m0.429s
26 0m0.483s 0m0.084s 0m0.411s
27 0m0.481s 0m0.067s 0m0.426s
28 0m0.481s 0m0.057s 0m0.436s
29 0m0.484s 0m0.085s 0m0.410s
30 0m0.484s 0m0.079s 0m0.416s
31 0m0.489s 0m0.070s 0m0.430s
32 0m0.486s 0m0.081s 0m0.419s
33 0m0.487s 0m0.098s 0m0.400s
34 0m0.676s 0m0.058s 0m0.442s
35 0m0.486s 0m0.079s 0m0.419s
36 0m0.484s 0m0.069s 0m0.424s
37 0m0.699s 0m0.082s 0m0.417s
38 0m0.485s 0m0.063s 0m0.434s
39 0m0.484s 0m0.071s 0m0.423s
40 0m0.488s 0m0.096s 0m0.403s
41 0m0.486s 0m0.081s 0m0.416s
42 0m0.481s 0m0.073s 0m0.420s
43 0m0.487s 0m0.070s 0m0.428s
44 0m0.487s 0m0.079s 0m0.420s
45 0m0.483s 0m0.069s 0m0.425s
46 0m0.488s 0m0.065s 0m0.434s
47 0m0.487s 0m0.103s 0m0.396s
48 0m0.481s 0m0.076s 0m0.417s
49 0m0.487s 0m0.079s 0m0.422s
50 0m0.485s 0m0.076s 0m0.419s
51 0m0.484s 0m0.070s 0m0.425s
52 0m0.496s 0m0.077s 0m0.430s
53 0m0.488s 0m0.069s 0m0.430s
54 0m0.484s 0m0.061s 0m0.433s
55 0m0.487s 0m0.078s 0m0.421s
56 0m0.490s 0m0.065s 0m0.437s
57 0m0.492s 0m0.092s 0m0.411s
58 0m0.483s 0m0.057s 0m0.440s
59 0m0.486s 0m0.069s 0m0.430s
60 0m0.483s 0m0.080s 0m0.413s
61 0m0.485s 0m0.059s 0m0.439s
62 0m0.483s 0m0.059s 0m0.438s
63 0m0.488s 0m0.082s 0m0.419s
64 0m0.547s 0m0.079s 0m0.440s
65 0m0.482s 0m0.079s 0m0.414s
66 0m0.482s 0m0.087s 0m0.409s
67 0m0.592s 0m0.082s 0m0.436s
68 0m0.481s 0m0.075s 0m0.417s
69 0m0.479s 0m0.069s 0m0.421s
70 0m0.685s 0m0.084s 0m0.411s
71 0m0.483s 0m0.082s 0m0.411s
72 0m0.762s 0m0.075s 0m0.452s
73 0m0.481s 0m0.065s 0m0.429s
74 0m0.477s 0m0.069s 0m0.421s
75 0m0.554s 0m0.094s 0m0.421s
76 0m0.482s 0m0.073s 0m0.422s
77 0m0.483s 0m0.080s 0m0.414s
78 0m0.485s 0m0.081s 0m0.415s
79 0m0.488s 0m0.077s 0m0.422s
80 0m0.669s 0m0.092s 0m0.425s
81 0m0.484s 0m0.069s 0m0.427s
82 0m0.485s 0m0.086s 0m0.410s
83 0m0.675s 0m0.082s 0m0.431s
84 0m0.485s 0m0.065s 0m0.431s
85 0m0.480s 0m0.065s 0m0.428s
86 0m0.484s 0m0.086s 0m0.407s
87 0m0.478s 0m0.080s 0m0.410s
88 0m0.751s 0m0.067s 0m0.449s
89 0m0.482s 0m0.082s 0m0.413s
90 0m0.488s 0m0.061s 0m0.440s
91 0m0.674s 0m0.080s 0m0.439s
92 0m0.481s 0m0.071s 0m0.422s
93 0m0.482s 0m0.054s 0m0.441s
94 0m0.634s 0m0.076s 0m0.430s
95 0m0.483s 0m0.084s 0m0.410s
96 0m0.485s 0m0.066s 0m0.431s
97 0m0.485s 0m0.087s 0m0.409s
98 0m0.481s 0m0.066s 0m0.428s
99 0m0.489s 0m0.073s 0m0.427s
100 0m0.600s 0m0.073s 0m0.441s

まとめ

ただファイルを消すだけなら-deleteを使う。

-deleteが使えない環境なら-exec rm -f {} +を利用するのがよさそう。(使えない環境が存在するのかは不明)

ファイルに特殊な文字列が入らないことが確定しているならxargs rm -fも選択肢としてあり。

参考

find -execとxargs

Man page of FIND

  1. findのdeleteオプションはマイナーなの?

  2. Man page of XARGS

1
0
1

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?