Solved

How do I back up within a directory?

Posted on 2004-04-13
9
259 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
Comment Utility
'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
Comment Utility
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
Comment Utility
pushd ./next/level
echo in `pwd` now
pushd
echo back in `pwd`
pushd
echo no in `pwd` again
popd
0
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
s/no/now/

(sorry for typos)
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 12

Expert Comment

by:stefan73
Comment Utility
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
Comment Utility
> cd ..
hence pushd, it does not have this problem (depending on shell, OS, or whatever)
;-)
0
 
LVL 12

Expert Comment

by:stefan73
Comment Utility
ahoffmann,
Yes, very helpful.

Stefan
0
 

Author Comment

by:roduno
Comment Utility
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
Comment Utility
My bad..... I wasn't putting a space between the cd and the ..
I got it now!  Thanks alot!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
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…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now