I want to delete all files with a specific extension - ".fal", in a folder and its subfolders, except the one named "*Original.fal". The problem is that I want to delete other files that have the same extension:
- *Original.fal.ds
- *Original.fal.ds.erg
- *Original.fal.ds.erg.neu
There are other ".fal"s that I want to delete as well, that don't have "Original" in them. Names vary all the time, so I can't delete specific names. The *Original.fal doesn't vary.
I can only get up to here:
$find /disk_2/people/z183464/DOE-Wellen -name "*.fal" \! -name "*Original.fal" -type f -exec echo rm {} \;
It would be great if the command can delete only in the folder (and it's subfolders) where it has been called (executed)
When I run the code it gives me an error:
- /disk_2/people/z183464/DOE-Wellen: is a directory
findsolution should work fine. The error message seems just because you typed your one-liner on two lines. That-type f-stuff should be on the same line as the stuff above, then it should function. Hint: use-exec echo rm {} \;to see what it would do before actually executing it without theecho.*Original.falwould match. You probably want ".fal.*" which will actually get all files that contain '.fal.' -- IOW, it will select all of the items you listed but not "*Original.fal".