Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Is this a valid file name 1.abc!``!+123 in Ubuntu?

I issued the command

rm 1.abc!``!+123 

and got error message

-bash: !``!+123: event not find

Why? How to I delete the file?

share|improve this question
add comment

2 Answers 2

up vote 8 down vote accepted

Just simply rm '1.abc!``!+123'. Note about '

Note:Quoting is used to remove the special meaning of certain characters or words to the shell. Quoting can be used to disable special treatment for special characters, to prevent reserved words from being recognized as such, and to prevent parameter expansion. Some special characters are: $ ` " !

share|improve this answer
4  
The ! invokes the Bash history expansion so it has to be protected by quotes or a preceding `` –  Florian Diesch Mar 1 '13 at 17:51
add comment

Yes, that is a valid file name. However, the shell treats those as special characters, so to use them in a file command, you will need to escape them using ':

rm '1.abc!``!+123'

According to the bash manpage,

! Start a history substitution, except when followed by a blank, newline, carriage return, = or ( (when the extglob shell option is enabled using the shopt builtin).

And

Command Substitution

Command substitution allows the output of a command to replace the command name. There are two forms:

$(command)

or

`command`

So if you want to use the ! or ` characters as regular characters, you need to escape them using ' so the shell doesn't try to start a history or command substitution.

share|improve this answer
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.