Solved

How do I back up within a directory?

Posted on 2004-04-13
9
262 Views
Last Modified: 2013-12-27
Seems like a simple question but I have not been able to find the answer.....Is there a way to backup a level within a directory in Solaris?  I usually will dig down into a multilevel directory and then cd back out to the main area and then have to dig back down into the directory to get to a level that was right above where I was previously.  Is there a command that will let me back my way out of a directory?
0
Comment
Question by:roduno
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 40

Accepted Solution

by:
jlevie earned 125 total points
ID: 10820108
'cd ..' will take you up one level, 'cd ../../' two levels, and 'cd ../../other-dir' will go up two levels and down into "other-dir."
0
 
LVL 48

Expert Comment

by:Tintin
ID: 10820111
There's a number of approaches (of which some are shell dependent).

In ksh/bash, you can do

cd -

to cd to the last directory you where in.

In csh/tcsh, you have the pushd and popd functions to pop/push directories onto a stack.

Another approach is to set up aliases for your favourite dirs, eg:

alias mydir='cd /path/to/some/long/dir'

0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 10820510
pushd ./next/level
echo in `pwd` now
pushd
echo back in `pwd`
pushd
echo no in `pwd` again
popd
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 51

Expert Comment

by:ahoffmann
ID: 10820518
s/no/now/

(sorry for typos)
0
 
LVL 12

Expert Comment

by:stefan73
ID: 10820985
Hi roduno,
Yes, "cd .." works. But be careful when your cd path contains soft links. ".." is a hard link to the parent directory. "cd .." might not get you back to the parent directory you expected.

Cheers,
Stefan
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 10822383
> cd ..
hence pushd, it does not have this problem (depending on shell, OS, or whatever)
;-)
0
 
LVL 12

Expert Comment

by:stefan73
ID: 10823158
ahoffmann,
Yes, very helpful.

Stefan
0
 

Author Comment

by:roduno
ID: 10838612
I must have a faulty or weird os because none of the above suggestions worked.  All I get when I try them is "not found".
0
 

Author Comment

by:roduno
ID: 10838725
My bad..... I wasn't putting a space between the cd and the ..
I got it now!  Thanks alot!
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question