From shell: delete all files using apostrophes

How to delete all files in an apostrophe folder?

eg:

Baird / Tunnel.jpg

Bach / Birds.jpg

This isn // 't good.png

I would like all these files to be deleted, but everything that does not have an apostrophe will remain untouched, for example:

this is good.jpg donotdelete.png

+3
source share
3 answers

In sh you could do

rm *\'*
+3
source

You can use the command find:

find . -name "*'*" -delete

As @Bryan noted in his comment, this will delete all files in the current directory and in all subdirectories . If you do not want to drop directories, use:

find . -name "*'*" -maxdepth 1 -delete

find .

+1

GNU

find /path/ -type f -name "*[']*" -exec rm {} +;
0

Source: https://habr.com/ru/post/1727530/


All Articles