From 2c10955690012c25a5d20893cf9549f1e63fe580 Mon Sep 17 00:00:00 2001 From: Michihito Shigemura Date: Fri, 27 Oct 2017 00:11:27 +0900 Subject: [PATCH] Add cheatsheet for xargs --no-run-if-empty --- cheat/cheatsheets/xargs | 4 ++++ 1 file changed, 4 insertions(+) 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