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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
05-18-2004, 04:54 PM
|
#1
|
Senior Member
Registered: Nov 2003
Location: Orlando FL
Distribution: Debian
Posts: 1,765
Rep:
|
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.
|
|
|
05-18-2004, 05:04 PM
|
#2
|
Senior Member
Registered: Jan 2003
Posts: 2,786
|
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.
|
|
|
05-18-2004, 05:08 PM
|
#3
|
Senior Member
Registered: Jun 2003
Location: California
Distribution: Slackware
Posts: 1,181
Rep:
|
Quotes should also work as well
|
|
|
05-18-2004, 05:11 PM
|
#4
|
Senior Member
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian Stable
Posts: 2,546
|
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.
|
|
|
05-18-2004, 08:30 PM
|
#5
|
Senior Member
Registered: Nov 2003
Location: Orlando FL
Distribution: Debian
Posts: 1,765
Original Poster
Rep:
|
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.
|
|
|
05-18-2004, 11:31 PM
|
#6
|
Senior Member
Registered: Mar 2003
Location: Burke, VA
Distribution: RHEL, Slackware, Ubuntu, Fedora
Posts: 1,418
Rep:
|
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
|
|
|
05-19-2004, 09:31 AM
|
#7
|
Senior Member
Registered: Nov 2003
Location: Orlando FL
Distribution: Debian
Posts: 1,765
Original Poster
Rep:
|
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.
|
|
|
All times are GMT -5. The time now is 09:27 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|