2
0
mirror of https://github.com/chubin/cheat.sheets synced 2024-11-19 03:25:44 +00:00

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.
This commit is contained in:
terminalforlife 2019-11-06 00:50:46 +00:00
parent 8e5e9dd0a4
commit 86007dd5db

View File

@ -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