Bash: Numbered Files in Find
source link: https://www.codesd.com/item/bash-numbered-files-in-find.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Bash: Numbered Files in Find
I was writing a bash script that finds and deletes the .blend1 and .blend2 files that blender creates as you edit and save .blend files. It contains lines in pairs like this:
find Documents -name "*.blend1" -exec rm -rf {} \;
find Documents -name "*.blend2" -exec rm -rf {} \;
This works just fine, though I was curious if it is at all possible to combine those two find commands some way, so that it would be just one command that finds and deletes both .blend1 and .blend2 files.
Not super-important, I'd just prefer it if my script were a little more compact.
find Documents -name '*.blend[12]' -delete
(-delete
is a GNU find extension.)
Other ways:
find Documents '(' -name '*.blend1' -o -name '*.blend2' ')' -delete
find Documents -name '*.blend*' -delete
Related Articles
Bash: Sort files from 'Find' by content
Try writing a bash file to find a specific string template and replace it with a new string from the arg command line using a shell script?
Script to group numbered files into folders
Create a Numbers file and open it with Numbers on iPad
is there a shell / bash for aliases & hellip; find . -type f -exec grep -l & lt; a word here & gt; {} \ ;;
How do I write a method in java that reads a text file and finds the number of occurrences of each character?
How to compare two csv files and find a difference using powershell
How to get file names when you drag files from Finder to your application
Reading in a corresponding xml and regex file to find the dimensions: Undefined error
To count a character in files by Find / Xargs / Sed
Getting the directory a bash script file is in
Batch file that finds a file name that contains a substring
How to have folders before any file in finder (Mac) programmatically?
Choose the highest numbered file - batch file
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK