Fedora - n00b - do these / \ have to be used ? an alternative command?


Why did a colleague use this command
cd /users\ folders/users-personal/

To get to this pwd
/users folders/users-personal

he could have gone
cd "users folders"
then
cd "users-personal"

but that was two lines of code I admit

is there an easier way to jump two directories if there is a space in the directory name of one of them without using / \?

 




fcekAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

farzanjCommented:
In the command
cd /users\ folders/users-personal/
The bolded slash is ESCAPING the space.  This way cd would know that it is still the name of the folder.

Otherwise, when it sees a space it thinks that it is the end of a folder name and probably another one is coming.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
wesly_chenCommented:
cd "/users folders/users-personal"
0
farzanjCommented:
Escaping means changing the usual meaning of a character, and use it literally.  In this case, a space delimits a folder name.  So to tell that it is still the same name, it has to escape it.
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

svgmucCommented:
You can also

> cd "user folders/users-personal"

The / separates directories (or folders).

The \ is an escape character and in this case makes the cd command ignore the blank character and consider it part of the name... If you left the \ off, it would assume user and folders were two different arguments.
0
farzanjCommented:
Yes there are certainly more than one ways to do the same thing.


he could have gone
cd "users folders"
then
cd "users-personal"

YES I AGREE.  You could break it into two commands.  Same thing
0
farzanjCommented:
And lastly, yes, you can avoid escaping a space if you quote it

so
cd users\ folders

would be same as
cd "users folders"
0
fcekAuthor Commented:

lastly is there a way to jump back to $ from here:

 [ed@server1 /]$ cd /users\ folders/users-personal/

I do it in two steps
cd ..
then another
cd ..
and I land here
[ed@server1 /]$



0
wesly_chenCommented:
cd ../..
or
say
$ pwd
/tmp
$ cd "/users folders/users-personal"
$ pwd
/users folders/users-personal
$ cd -
$ pwd
/tmp
0
TintinCommented:
If your shell is bash, ksh or zsh, you can go to the last directory you were in by doing

cd -

Open in new window

0
fcekAuthor Commented:
Thanks everyone
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.