2

Bash: Numbered Files in Find

 2 years ago
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

advertisements

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

I have the line: find -maxdepth 1 -type f -iname '*key*' -not -name '*~' I want to extract the contents (which should be text) of all the files returned and pipe that into sort to be sorted alphabetically. I've tried piping the output of the above li

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?

I am trying write a bash file to find a string in a .txt file using shell script and want to replace same with new string. The string pattern which I am trying find {{asdf}} and I want to replace it with ghjk from command line arg. I tried with the f

Script to group numbered files into folders

I have around a million files in one folder in the form xxxx_description.jpg where xxx is a number ranging from 100 to an unknown upper. The list is similar to this: 146467_description1.jpg 146467_description2.jpg 146467_description3.jpg 146467_descr

Create a Numbers file and open it with Numbers on iPad

I would like to do a task that is quite simple on other OS, but it is not so trivial on iOS. Namely, I want to create file and open it in Numbers. I can preview the file with UIDocumentInteractionController and then offer it to user that he/she opens

is there a shell / bash for aliases & hellip; find . -type f -exec grep -l & lt; a word here & gt; {} \ ;;

basically, this command does a recursive grep through all files in all sub-directories and I use it ALOT but it's looooong and takes awhile to type so I was wondering if instead of... $ find . -type f -exec grep -l <some word here> {} \;; that there

How do I write a method in java that reads a text file and finds the number of occurrences of each character?

How do I write a method in java that reads a text file and finds the number of occurrences of each character? Then after it stores the items into an arraylist as you read them.First open the .txt file and read its contents then create a Hashmap and i

How to compare two csv files and find a difference using powershell

I have two csv files , I want to compare both files and find difference.It contains user_id I tried with compare-object, diff but could not achieve. like AD_Users.csv Oracle_Users.csv both contains user id , output should be like AD user does not exi

How to get file names when you drag files from Finder to your application

I'm trying to let my NSView accept files which you can drag and drop from Finder. I've already checked the documentation (https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/DragandDrop/Tasks/acceptingdrags.html#//apple_ref/doc/uid

Reading in a corresponding xml and regex file to find the dimensions: Undefined error

I've been working on a project taking in .svg files and finding their dimensions. Instead of converting them to png, or using pysvg see (Best way of Getting Swf File Dimensions with Python) I am not trying to simply scan the xml for the dimensions. I

To count a character in files by Find / Xargs / Sed

How can you count the number of the character < in your files? I am trying to count the number of the character "<" in my files, similarly as in Vim by %s/<//gn I run find * -type f | xargs sed 's/<//gn' I get sed: -e expression #1,

Getting the directory a bash script file is in

How can I get the directory a bash script file is in, when that script file is included from another (which makes it different from this question)? /script1.sh . /dir2/script2.sh /dir2/script2.sh # echoes "/dir2" echo whatevergetsthatdir This is

Batch file that finds a file name that contains a substring

I want to write a batch file to find all .vsdm files and the file name must contain a substring "2.4". But my code is telling me that all my .vsdm files contains the substring "2.4" which is not correct. FOR /R %completepath% %%G IN (*

How to have folders before any file in finder (Mac) programmatically?

i am newbie to mac. I want to have the folder's first before any other file in finder through my cocoa app? Can anyone suggest me any way how can i do this like xtraFinder,PathFinder etc apps do? I have gone through the followings links.One way is th

Choose the highest numbered file - batch file

I have a directory full of .jar files, named progressively like so: version-1.jar version-2.jar version-3.jar I am trying to select the highest numbered file. Is there any really simple way to do it? Because doing .\version*.jar causes an error, pres

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK