LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-12-2013, 08:21 PM   #1
Dafydd
Member
 
Registered: Oct 2008
Posts: 344

Rep: Reputation: 29
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
 
Old 10-12-2013, 09:01 PM   #2
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,258
Blog Entries: 24

Rep: Reputation: 4193Reputation: 4193Reputation: 4193Reputation: 4193Reputation: 4193Reputation: 4193Reputation: 4193Reputation: 4193Reputation: 4193Reputation: 4193Reputation: 4193
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.

Last edited by astrogeek; 10-12-2013 at 09:08 PM.
 
1 members found this post helpful.
Old 10-12-2013, 10:11 PM   #3
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
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.
 
1 members found this post helpful.
Old 10-13-2013, 01:02 AM   #4
Dafydd
Member
 
Registered: Oct 2008
Posts: 344

Original Poster
Rep: Reputation: 29
Quote:
Originally Posted by lleb View Post
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.
 
Old 10-13-2013, 10:14 AM   #5
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
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.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Decypting file if see bad file then move to bad dir dotran Linux - Newbie 9 11-15-2012 01:46 PM
"Mount: wrong file system type, bad option, bad superblock" User Name. Linux - Newbie 9 09-03-2008 03:40 PM
apt-file returns nothing; 'bad file descriptor' overbored Debian 3 10-03-2004 09:13 PM
wrong fs type ,bad option, bad superblock on /dev/hda3, or too many mounted file syst Vencalator Linux - Newbie 4 09-20-2003 01:58 PM
wrong fs type, bad option, bad superblock on /dev/cdrom, or too many mounted file sy TheCyberDude Linux - Software 1 02-11-2002 12:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration