2

I have a file with the name like ?????????????????????? ???????????????????????? ??????????.png in my directory. It seems to me that file was created under windows with russian name. I pulled it with git and now I am unable to compile my program. And I am unable to delete it in debian.

rm: cannot remove `??????????????????????': No such file or directory

rm: cannot remove `????????????????????????': No such file or directory

rm: cannot remove `??????????.png': No such file or directory

I tried to use quotes around file name, but it doesn't work.

How should delete files with names like this?

1
  • 1
    The question marks probably stand for unrecognized unicode characters--I would try switching to a terminal font with unicode support for Russian characters.
    – isturdy
    Nov 24, 2012 at 14:17

2 Answers 2

4

Just use rm -i <wildcard>...

(py26_dfl)[mpenning@Bucksnort ~]$ rm -i *ng
rm: remove regular file `IMAG0004-1.png'? n
rm: remove regular file `??????????.png'? y
(py26_dfl)[mpenning@Bucksnort ~]$
0
3

The use of wildcards, as suggested in another answer, is often the faster way to select a subset of files from your directory, but not always it is possible to use it (e.g. in the previous case at least you have the extension suffix in understandable characters).

rm -i *ng   # means remove all files that finish for ng

Another way can be to use the inode number of the file.
With an ls -i you will have the list of the files in the current directory with the inode number followed from the file name. It follows an example, obtained with ls -i1 just to have the output with a file for each line:

14549004 Various_Command_.sh
14549512 Convert_Scan_Png_To_Jpg.sh
14579439 FILE_TO_DELETE

After you can delete or move or execute any command you want, selecting the file by its inode number. E.g: to remove the file FILE_TO_DELETE with the inode number 14579439 it's possible to write:

find . -inum 14579439 -exec rm -i {} \;

Note: the option -i after the remove command exists to force the system to prompt before every removal.
For the use of find you can read the man page or search on web some tutorial.

1
  • If confirmation is not required, an alternative is to do e.g. find . -inum 36384549 to view the files. Then just find . -inum 36384549 | xargs rm to remove them all. I find that syntax more intuitive and easier to remember.
    – Nagev
    May 31, 2018 at 14:13

You must log in to answer this question.