Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


  Search this Thread
Old 05-18-2004, 05:54 PM   #1
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.


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, 06:04 PM   #2
Senior Member
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 373Reputation: 373Reputation: 373Reputation: 373
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, 06:08 PM   #3
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, 06:11 PM   #4
Senior Member
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian 9 Stretch
Posts: 2,299
Blog Entries: 8

Rep: Reputation: 368Reputation: 368Reputation: 368Reputation: 368
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, 09:30 PM   #5
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-19-2004, 12:31 AM   #6
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.

Old 05-19-2004, 10:31 AM   #7
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.


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

All times are GMT -5. The time now is 07:30 AM.

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