[H-GEN] Useful not so obvious tips
Greg Black
gjb at gbch.net
Mon Oct 25 02:26:22 EDT 2004
On 2004-10-25, Anthony Irwin wrote:
> Greg Black wrote:
>> Have you learnt about pushd and popd? I find pushd the thing I
>> use most. (They're shell builtins like cd, so they're shell
>> specific, but I don't think any modern shell lacks them, except
>> real Bourne shells of course.)
>
> I haven't really used it before did a quick google and from what I saw
> you type pushd newdirectory then you can change between multiple
> directory paths by typing pushd +1
>
> I am not fully sure how you would effectively use it though I know that
> you could have 4 or 5 or more directories and change to them by going
> pushd +number is it a matter of remembering the sequence of the
> directories and where you are or can you give specific numbers or names
> to directories.
There are two common scenarios.
You just want to briefly do something in another directory, so
you say "pushd newdir", do your stuff and then "popd" to go back
where you started from. And, if "newdir" was not the one you
wanted, you'd then use "cd foo" to get to the right one and
"popd" would still get you back to the start point.
Alternatively, you may want to move between 5 directories. So
you pushd to each one. As you do, the shell will echo the
current list to remind you what it is and where you are.
But if you do so much stuff that the list has scrolled off your
screen and you can't remember it, you can just use the "dirs"
command to get the list, and then you can do "pushd +3" to move
to the one you want.
It's one of those things that is easiest to understand if you
play with it.
Cheers, Greg
More information about the General
mailing list