LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   bad charecter in file name (https://www.linuxquestions.org/questions/linux-general-1/bad-charecter-in-file-name-4175480566/)

Dafydd 10-12-2013 08:21 PM

bad charecter in file name
 
I have a file name with an exclamation point in it.
Who do you know!.html
No matter what I use, I always get this message:
Quote:

bash: !.html": event not found
I have tried
Code:

cp, rename. rename.ul, mv, chrome, firefox, opera, konqueror,
I have searched the web and found several scrips to remove un-wanted charechter from a file title, but none that deals with the exlplaintion mark. I have tried enclosing the fie name in quotation marks. Single quotes. escaping............

All return the above error or produce no results.

Since the word 'bash' shows up in the error message, is this 'bash' causing this problem?????

Is there a way to rename this file? Any help will be appreciated.
Thanks
Dave

astrogeek 10-12-2013 09:01 PM

If it is the only file with the name beginning with 'Who do you' then this should work to remove or rename it:

Code:

rm 'Who do you'*

mv 'Who do you'* newfile.html

rm Who\ do\ you\ know\ \!.html

Just tested, all of the above work.

lleb 10-12-2013 10:11 PM

you can always put a \ in front of the ! to tell the system to treat ! as a char and not a command.

example:

Code:

mv foo\!.com to foo.com
would work.

Dafydd 10-13-2013 01:02 AM

Quote:

Originally Posted by lleb (Post 5044700)
you can always put a \ in front of the ! to tell the system to treat ! as a char and not a command.

example:

Code:

mv foo\!.com to foo.com
would work.

I tried escaping it. Did not work. The examples I saw on using this had to deal with strings inside of filed. Not file names. Although I could have quit reading to early.


Thaksfor the reply.

lleb 10-13-2013 10:14 AM

you can always rename the file with the inode number:

Code:

[user@user New_Zealand_Wallpapers]$ ls -laF
total 10472
drwxrwxr-x.  2 ray ray    4096 Sep 11 12:54 ./
drwx------. 35 ray ray    4096 Oct 12 12:55 ../
-rw-rw-r--.  1 ray ray  747926 Aug  3 21:25 Auckland_2.jpg
-rw-rw-r--.  1 ray ray  766867 Aug  3 21:20 Auckland.jpg
-rw-rw-r--.  1 ray ray  352804 Aug  3 21:32 Bay_of_Islands.jpg

[user@user New_Zealand_Wallpapers]$ ls -il
total 10464
14419483 -rw-rw-r--. 1 ray ray  747926 Aug  3 21:25 Auckland_2.jpg
14419480 -rw-rw-r--. 1 ray ray  766867 Aug  3 21:20 Auckland.jpg
14419484 -rw-rw-r--. 1 ray ray  352804 Aug  3 21:32 Bay_of_Islands.jpg

http://www.cyberciti.biz/tips/delete...de-number.html

you dont have to remove, but just mv the file to an other name. process is basically the same.


All times are GMT -5. The time now is 08:13 PM.