空の入力をパイプするときに完全なディレクトリサイズを計算、停止する方法

空の入力をパイプするときに完全なディレクトリサイズを計算、停止する方法
[emdfqmm@nfwne ncndnkln]$ ll -h | grep "Oct" | grep "2018" | xargs du -ch
5.0G    ./something
5.0G    .
5.0G    total

[emdfqmm@nfwne ncndnkln]$ ll -h | grep "Oct" | grep "2018" | wc -l
0

空の入力がある場合は、ディレクトリ全体のサイズを計算します。これを停止する方法

ベストアンサー1

xargs入力が与えられていない場合は、実行しないことを選択できます。

-r, --no-run-if-empty
  If the standard input does not contain any nonblanks, do not run
  the command.  Normally, the command is run once even if there is
  no input.  This option is a GNU extension.

だから代わりにそれを使用してくださいxargs -r du -ch

おすすめ記事