Why doesn’t find/rm -iname ‘*phptheadmin’ delete phpMyAdmin-Version-XYZ.zip

findrm

I have this following code:

find ./ -iname '*phpmyadmin' -exec rm -rf {} \;

It deletes a dir called phpmyadmin, but it does not delete a file called phpMyAdmin-Version-XYZ.zip

Even if I remove the -rf, it still won't delete it (probably because a second problem with the -iname not affecting case insensitivity).

  1. Is there a way to delete any inode in a single rm (file, dir, softlink)?
  2. Why does adding the -iname not have an effect?

Note: I didn't find a "delete any inode" argument in man rm.

Best Answer

The problem is that you are matching a file that ends in phpmyadmin (case-insensitively) by using the pattern *phpmyadmin. To get any file that contains the string phpmyadmin (case-insensitively), use -iname '*phpmyadmin*':

find ./ -iname '*phpmyadmin*' -exec rm -rf {} \;

Perhaps getting the matched files before removal would be sane:

find ./ -iname '*phpmyadmin*'

To answer your first question, there is no option in rm in userspace to deal with inodes.

Related Question