VK.
VK.

Reputation: 501

How to remove this file with special characters

The file I'm trying to remove contains special characters in file name. This is how the file looks from vim editor (if I open the directory through vi) -

<200c>minaldi.pdf

I tried all possible way I knew for file removal e.g. find with "inum", using escape sequence but nothing seems to help.

I tried -

find . -type f -inum 37700 -exec rm '{}' \;
rm: cannot remove `./‌minaldi.pdf': No such file or directory 

Here 37700 is the inum for the file.

Here's the file name using ls | cat -v command -

M-bM-^@M-^Lminaldi.pdf

and using ls | od -bc command -

0000000 342 200 214 155 151 156 141 154 144 151 056 160 144 146 012
        342 200 214   m   i   n   a   l   d   i   .   p   d   f  \n
0000017

Upvotes: 1

Views: 1469

Answers (3)

Ipor Sircer
Ipor Sircer

Reputation: 3141

You can use find's internal delete parameter:

find . -type f -inum 37700 -delete

Upvotes: 1

Robert
Robert

Reputation: 8506

If it's only for a one time remove and not for use in a script, use -i for interactive. Specify as much as you can for the file name, so that you don't have to go through too many file names:

rm -i *minaldi.pdf

This will ask for each file matching the pattern whether you want to delete it.

Upvotes: 0

iBug
iBug

Reputation: 37217

Use echo to escape that:

rm "$(echo -en './‌\xE2\x80\x8Cminaldi.pdf')"

Upvotes: 0

Related Questions