Fedora Linux Support Community & Resources Center
  #1  
Old 2nd September 2012, 06:45 PM
leonardevens Offline
Registered User
 
Join Date: Dec 2006
Age: 81
Posts: 523
linuxfirefox
Having trouble with file name with spaces

If I do
cd /run/media/len/My\ Book/Windows\ backup
I get put in the right directory.

However if i do
BACK="/run/media/len/My\ Book/Windows\ backup"
echo $BACK
gives me the exact same sequence
but
cd $BACK
gives me
bash: cd: /run/media/len/My\: No such file or directory
I've tried various different ways of writing it, but I can't get it to work.

The spaces in the names were created long ago, probably under windows, and I don't see right now how
to rename them.

How do I get cd $BACK to work. (I need it in a shell script.)
Reply With Quote
  #2  
Old 2nd September 2012, 07:09 PM
StyxD Offline
Registered User
 
Join Date: Apr 2010
Posts: 49
linuxfirefox
Re: Having trouble with file name with spaces

First, don't escape spaces inside quotes, because you'll be getting literal backslashes. Either do:
BACK="/run/media/len/My Book/Windows backup"
or
BACK=/run/media/len/My\ Book/Windows\ backup

And then:
cd "$BACK"
Reply With Quote
  #3  
Old 2nd September 2012, 08:33 PM
leonardevens Offline
Registered User
 
Join Date: Dec 2006
Age: 81
Posts: 523
linuxfirefox
Re: Having trouble with file name with spaces

Quote:
Originally Posted by StyxD View Post
First, don't escape spaces inside quotes, because you'll be getting literal backslashes. Either do:
BACK="/run/media/len/My Book/Windows backup"
or
BACK=/run/media/len/My\ Book/Windows\ backup

And then:
cd "$BACK"
Thank you. I thought I had tried cd "$BACK", and it didn't work, but perhaps I didn't have one of your choices for BACK.
Reply With Quote
Reply

Tags
file, spaces, trouble

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
I am having trouble opening a file Socrates440 Using Fedora 3 26th June 2012 09:27 AM
spaces in file names make my script choke unknowndevice Using Fedora 5 6th April 2009 11:59 PM
Trouble w/ Berkeley DB header file. nardinc Programming & Packaging 9 15th January 2007 04:59 AM
Trouble with xfig->File->export (and fig2dev) on FC4 dedded Using Fedora 0 25th August 2005 05:01 AM
Folders and File names with spaces Rever75 Using Fedora 3 18th August 2005 03:59 PM


Current GMT-time: 22:09 (Friday, 26-12-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat
...Puntarenas-Centro, Costa Rica. Instagram Photos - Aeroport Paris Orly Ouest Travel Photos on Instagram - Gratte Ciel Lyon Photos on Instagram - Blue Veranda Suites Boracay Travel Photos - Malibu, Ca Photos on Instagram