Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Nov 24 '12 at 17:31

This question came from our site for professional and enthusiast programmers.

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 '12 at 14:17
    
Thank you, Mike! It works! –  Anton Bondarenko Nov 24 '12 at 14:22

2 Answers 2

up vote 2 down vote accepted

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 ~]$
share|improve this answer
    
Thank you, Mike! It works! –  Anton Bondarenko Nov 24 '12 at 14:25

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.