From 6500f80c97d2745230d35a61d2236a56a987ca58 Mon Sep 17 00:00:00 2001 From: Jason Edgecombe Date: Sat, 17 Dec 2022 17:15:35 -0500 Subject: [PATCH 1/7] xargs: Add YAML front-matter --- xargs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xargs b/xargs index b4a3ace..f3b713a 100644 --- a/xargs +++ b/xargs @@ -1,3 +1,7 @@ +--- +syntax: bash +--- + # To Find all file name ending with .pdf and remove them find -name *.pdf | xargs rm -rf From d8b640322e9e00727d0ad0b3125ad18bcb3a3d95 Mon Sep 17 00:00:00 2001 From: Jason Edgecombe Date: Sat, 17 Dec 2022 17:31:12 -0500 Subject: [PATCH 2/7] xargs: make file search more selective to only include files --- xargs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xargs b/xargs index f3b713a..01a2b35 100644 --- a/xargs +++ b/xargs @@ -2,8 +2,8 @@ syntax: bash --- -# To Find all file name ending with .pdf and remove them -find -name *.pdf | xargs rm -rf +# Find all files whose names end with .pdf and remove them +find -type f -name *.pdf | xargs rm -f # if file name contains spaces you should use this instead find -name *.pdf | xargs -I{} rm -rf '{}' From f38e2213b0ced576c2ba203ad05622512494acc5 Mon Sep 17 00:00:00 2001 From: Jason Edgecombe Date: Sat, 17 Dec 2022 17:32:05 -0500 Subject: [PATCH 3/7] xargs: Use --null for weird file names -I'{}' breaks when files contain quotes while --null does not. --- xargs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xargs b/xargs index 01a2b35..acb2440 100644 --- a/xargs +++ b/xargs @@ -5,8 +5,9 @@ syntax: bash # Find all files whose names end with .pdf and remove them find -type f -name *.pdf | xargs rm -f -# if file name contains spaces you should use this instead -find -name *.pdf | xargs -I{} rm -rf '{}' +# If file names contain special characters, you should use this instead. +# Special characters include spaces, quotes, parenthesis, unicode, etc. +find -type f -name *.pdf -print0 | xargs --null rm -f # Will show every .pdf like: # &toto.pdf= From 8396b84bee7a14efac3517633a6c2075804f8d66 Mon Sep 17 00:00:00 2001 From: Jason Edgecombe Date: Sat, 17 Dec 2022 20:26:46 -0500 Subject: [PATCH 4/7] xargs: Add --max-procs example --- xargs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xargs b/xargs index acb2440..b05e094 100644 --- a/xargs +++ b/xargs @@ -9,6 +9,9 @@ find -type f -name *.pdf | xargs rm -f # Special characters include spaces, quotes, parenthesis, unicode, etc. find -type f -name *.pdf -print0 | xargs --null rm -f +# Run 4 "rm" commands in parallel +find -name "*.pdf" | xargs --max-procs=4 rm -f + # Will show every .pdf like: # &toto.pdf= # &titi.pdf= From 2359ce670b680a22663cb5b88bd24ef1ce37b276 Mon Sep 17 00:00:00 2001 From: Jason Edgecombe Date: Sun, 18 Dec 2022 15:24:17 -0500 Subject: [PATCH 5/7] Update xargs Co-authored-by: Emily Grace Seville --- xargs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xargs b/xargs index b05e094..2e56d0a 100644 --- a/xargs +++ b/xargs @@ -2,8 +2,8 @@ syntax: bash --- -# Find all files whose names end with .pdf and remove them -find -type f -name *.pdf | xargs rm -f +# Find all files whose names end with .pdf and remove them: +find -type f -name '*.pdf' | xargs rm -f # If file names contain special characters, you should use this instead. # Special characters include spaces, quotes, parenthesis, unicode, etc. From 6f3a306720ed51fa26704b2dd4e0ec980935d310 Mon Sep 17 00:00:00 2001 From: Jason Edgecombe Date: Sun, 18 Dec 2022 15:24:40 -0500 Subject: [PATCH 6/7] Update xargs Co-authored-by: Emily Grace Seville --- xargs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xargs b/xargs index 2e56d0a..56c9bcb 100644 --- a/xargs +++ b/xargs @@ -6,8 +6,8 @@ syntax: bash find -type f -name '*.pdf' | xargs rm -f # If file names contain special characters, you should use this instead. -# Special characters include spaces, quotes, parenthesis, unicode, etc. -find -type f -name *.pdf -print0 | xargs --null rm -f +# Special characters include spaces, quotes, parenthesis, unicode, etc: +find -type f -name '*.pdf' -print0 | xargs --null rm -f # Run 4 "rm" commands in parallel find -name "*.pdf" | xargs --max-procs=4 rm -f From 1df08c374482cbb2f2befd4c22f4b325adec2de2 Mon Sep 17 00:00:00 2001 From: Jason Edgecombe Date: Sun, 18 Dec 2022 15:24:57 -0500 Subject: [PATCH 7/7] Update xargs Co-authored-by: Emily Grace Seville --- xargs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xargs b/xargs index 56c9bcb..10eaa42 100644 --- a/xargs +++ b/xargs @@ -9,8 +9,8 @@ find -type f -name '*.pdf' | xargs rm -f # Special characters include spaces, quotes, parenthesis, unicode, etc: find -type f -name '*.pdf' -print0 | xargs --null rm -f -# Run 4 "rm" commands in parallel -find -name "*.pdf" | xargs --max-procs=4 rm -f +# Run 4 `rm` commands in parallel +find -name '*.pdf' | xargs --max-procs=4 rm -f # Will show every .pdf like: # &toto.pdf=