LinuxQuestions.org
Visit Jeremy's Blog.
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 05-18-2004, 04:54 PM   #1
Lleb_KCir
Senior Member
 
Registered: Nov 2003
Location: Orlando FL
Distribution: Debian
Posts: 1,765

Rep: Reputation: 45
how to rename via CLI with a space in the name


i have a few files in my home dir that have spaces in them and i want to rename them to have _ instead of spaces.

problem i run into is with mv command every time i put a space in there the system thinks its a new file and gives me an error.

example:

file name what ever.ddd

i type:

mv file name what ever.ddd file_name_what_ever.ddd

and get an error. is there a way around this in the CLI? im currenly working via SSH over cygwin. i just dont know how to start natalis, or what ever the GUI file program is called.
 
Old 05-18-2004, 05:04 PM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
You can try this: place a \ in front of any space in the filename on the command line. For instance, the command you used earlier would be:

mv file\ name\ what\ ever.ddd file_name_what_ever.ddd

That works for me in the terminal (in both Red Hat 8 and 9). I don't know if cygwin would have a problem with it.
 
Old 05-18-2004, 05:08 PM   #3
Poetics
Senior Member
 
Registered: Jun 2003
Location: California
Distribution: Slackware
Posts: 1,181

Rep: Reputation: 49
Quotes should also work as well
 
Old 05-18-2004, 05:11 PM   #4
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian Stable
Posts: 2,546
Blog Entries: 8

Rep: Reputation: 465Reputation: 465Reputation: 465Reputation: 465Reputation: 465
Put the file name in double quotes, like this:

mv "file name what ever.ddd" file_name_what_ever.ddd

BTW, putting filenames in quotes generally works in Windows also, if you care.
 
Old 05-18-2004, 08:30 PM   #5
Lleb_KCir
Senior Member
 
Registered: Nov 2003
Location: Orlando FL
Distribution: Debian
Posts: 1,765

Original Poster
Rep: Reputation: 45
great answeres. thanks for the help. ill keep that in mind. had no clue how to get around that in *nix, and know very little about windows cmd line as i did little with dos.
 
Old 05-18-2004, 11:31 PM   #6
Shade
Senior Member
 
Registered: Mar 2003
Location: Burke, VA
Distribution: RHEL, Slackware, Ubuntu, Fedora
Posts: 1,418
Blog Entries: 1

Rep: Reputation: 46
I use the tab completion in bash wherever possible. It's great -- and it takes care of that for you

Type out what<hittab> and it fills in the \ ever.ddd for you
it's quite useful.

--Shade
 
Old 05-19-2004, 09:31 AM   #7
Lleb_KCir
Senior Member
 
Registered: Nov 2003
Location: Orlando FL
Distribution: Debian
Posts: 1,765

Original Poster
Rep: Reputation: 45
i normaly do too, but being a complete newB to linux i had no idea what those \ were for so i deleted them.

now i know its ok for them to be there.
 
  


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
how to reduce swap space and reclaim the space grantm Linux - Newbie 7 08-16-2012 07:05 AM
notify user space application from the kernel space lordofring Linux - Software 2 06-22-2009 12:32 PM
Viewing Drive Space via CLI carlosinfl Linux - General 2 10-23-2005 11:03 AM
awk cli to rename a list of files... pld Linux - General 4 02-15-2005 10:57 PM
Not enough space for root directory on a drive with 50g free space??? auoq Linux - Newbie 1 10-13-2004 12:44 PM

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

All times are GMT -5. The time now is 09:10 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