Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to remove a file named "?" in linux? [closed]

I created a file named "?", is anybody know how to delete it?

It seems that ? is a special character in linux, I use Redhat as my OS.

I have already tried

    rm ?
    rm "?"
    rm \?

They all failed and I got the error indicated that the file doesn't exist.

like image 258
Yang Avatar asked Nov 12 '13 06:11

Yang


People also ask

How would you remove a file called in Linux?

The rm command deletes files in a Linux. The command unlinks the data from the file name, allowing the user to overwrite on that particular storage space. Wildcards can be used with this command.

How do you delete all files that end with a certain name Linux?

Using rm Command To remove a file with a particular extension, use the command 'rm'. This command is very easy to use, and its syntax is something like this. In the appropriate command, 'filename1', 'filename2', etc., refer to the names, plus their full paths.

How do I delete a file in Linux without prompt?

If you do not want a prompt before deleting the directory and its contents, use the -rf flag.

How do I delete a file name?

Alternatively, head to the folder containing the files you want to delete, hit Shift + Right Click, and select Open a command window here. Then input "del [filename]" and press Enter.

Which command is used for removing file named?

The rm command is used to delete files.


2 Answers

You can delete the file by its inode number. see the output bellow:

alplab:~/cad# ls -il
63051 -rw-r--r--    1 root     root             0 Nov 12 11:48 ?
alplab:~/cad# find . -inum 63051 -exec rm -i {} \;

I used the "find" command to delete the file with the inode number 63051 (the inode belonging to my "?" file).

like image 173
alacerda Avatar answered Oct 04 '22 05:10

alacerda


rm \? and rm "?" are both perfectly good ways to delete a file named ?. If they didn't work, and you still seem to have a file name ?, then it is most likely that the ? being shown is not really a ?, but rather the result of substituting an unprintable character with a ?. To see what the file is really called (with GNU ls) try:

ls --quoting-style=escape
like image 37
rici Avatar answered Oct 04 '22 03:10

rici