From 86007dd5db431099e44d044d879bc5e3c6221d0d Mon Sep 17 00:00:00 2001 From: terminalforlife Date: Wed, 6 Nov 2019 00:50:46 +0000 Subject: [PATCH] Delete extension-specific files using logic This was taken from my own notes amassed over several years. Commands like these are a real time-saver. A lot of people, I imagine, will probably use `-exec rm {} \+` which is fine and all, but it's another process you'd have to launch, which isn't necessary at all, unless you need certain `rm` functionality. --- sheets/find | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sheets/find b/sheets/find index 8b4a956..abe454d 100644 --- a/sheets/find +++ b/sheets/find @@ -53,3 +53,6 @@ find . -iname '*.txt' -exec vim {} \+ # Find all files with extension '.png' and rename them by changing extension to # '.jpg' (base name is preserved) find . -type f -iname '*.png' -exec bash -c 'mv "$0" "${0%.*}.jpg"' {} \; + +# Use logic and grouping to delete extension-specific files. +find \( -iname "*.jpg" -or -iname "*.sfv" -or -iname "*.xspf" \) -type f -delete