Link to home
Start Free TrialLog in
Avatar of David
DavidFlag for United States of America

asked on

linux directory traversal in one line

not sure how to explain this...

i'm not trying to do a directory traversal attack, i could do that in multiple lines with a script

i want to go back a directory "cd .."
then forward in the parent directory "cd .. cd johndoe"

.
..
/home/johnsmith
/home/johndoe
/home
/bin
/var
/etc

i want to do it in one line please


thanks

-dave.j
Avatar of David Favor
David Favor
Flag of United States of America image

find $dir -type d

Open in new window

Surely you've thought of this, so likely you'll require expanding your question to add more clarity about what you're asking to accomplish.
Avatar of David

ASKER

i just want to go from johnsmith to johndoe in one line

i just don't know what to call it... what to search for

in home/johnsmith

i want to cd down a directory ans save myself the trouble of:
cd ..
cd johndoe

i want to do cd .. cd johndoe     (in one line)

don't need to find i know the structure of my directories and where i want to go, just not how to put it in one line
ASKER CERTIFIED SOLUTION
Avatar of robocat
robocat

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Likely what robocat suggested...

cd ../johndoe

Open in new window

Avatar of noci
noci

In Unix/Linux one specifies a path, (including a name at the end) not just a name.
path can be absolute (starting with a /)  or relative (not starting with a /).

that work on any place a directory (also a file, only one that contains references to files).
or a file needs to be specified. Also devices are referenced using a name in the file system.
You own terminal (where you are logged on) :  /dev/tty,
a disk: /dev/sda
a partition is /dev/sda1...
(Exception to this: network devices and X-displays).