Solved

How do I back up within a directory?

Posted on 2004-04-13
9
265 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Parsing a file using ksh 10 72
aix tls version 6 435
AIX 5.x set up arrow to recall 11 58
need to remove or skip  grub protection password in ubuntu on boot time 2 79
In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
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…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

820 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