diff --git a/cheat/cheatsheets/xargs b/cheat/cheatsheets/xargs index 44bf20a..a1391f3 100644 --- a/cheat/cheatsheets/xargs +++ b/cheat/cheatsheets/xargs @@ -10,3 +10,7 @@ find -name *.pdf | xargs -I{} rm -rf '{}' # -n1 => One file by one file. ( -n2 => 2 files by 2 files ) find -name *.pdf | xargs -I{} -n1 echo '&{}=' + +# If find returns no result, do not run rm +# This option is a GNU extension. +find -name "*.pdf" | xargs --no-run-if-empty rm