0

let's say I have a directory like this:

IIS1
IIS1-DVLP
FS
IIS1.zip
IIS1-DVLP.zip
RA.zip

the top 3 entries are folders, the bottom 3 entries are zip files.

If I now want to delete IIS1 and IIS1.zip I tried the following:

admin@Server:/volumeUSB1/usbshare1-2$ find -name "IIS1" -o -name "IIS1.zip"
./IIS1
./IIS1.zip

which found me the things I want to delete, so I simply thought I can add my -delete

admin@Server:/volumeUSB1/usbshare1-2$ find -name "IIS1" -o -name "IIS1.zip" -delete
admin@Server:/volumeUSB1/usbshare1-2$ ls -l
total 1
drwxrwxrwx 1 admin users   0 Feb 11 14:03 IIS1
drwxrwxrwx 1 admin users   0 Feb 11 14:03 IIS1-DVLP
-rwxrwxrwx 1 admin users 164 Feb 11 14:03 IIS1-DVLP.zip

but my folder somehow survived!

How would I do it in this case? I can't use a Wildcard * because IIS1-DVLP would also match that wildcard

This folder only has subfolders or zip files in it. either both things exist (like as for IIS1) or only a folder or only a zip file. I want to be able to delete whatever exists.

SimonS
  • 1,891
  • 1
  • 29
  • 53
  • This is a precedence problem; the `-o` binds the `-delete` to only one side of the "or". – tripleee Feb 11 '21 at 13:15
  • @tripleee so much to leeeeaaaarn aaah. ok thanks. since this was so easy to answer, should I delete the question or do you want to expand it to an answer? – SimonS Feb 11 '21 at 13:18
  • Just leave it, duplicates which take this long to find (6 minutes!!!) will probably benefit from having duplicates which phrase the question in a different manner. – tripleee Feb 11 '21 at 13:22
  • @tripleee I mean I know what you mean by duplicate, but I don't really think this is a duplicate, since I knew how to find them, i simply didn't know that the `-delete` is only for the right hand side of `-o`, which is fascinating btw. Bash and PowerShell (the only thing I know well) are so completely different – SimonS Feb 11 '21 at 13:31

0 Answers0