Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

bash-shortcut for cd ../../../..

Status
Not open for further replies.

stefanwagner

Programmer
Oct 19, 2003
2,373
DE
I made a microscript for bash, to be included in .bash_profile, to jump up multiple directories at once.
Code:
# instead of 
cd ../../../..
# you could use 
up 4
to jump 4 steps up in the directory hierarchie.

It's short and simple:
Code:
# (c) 2007 stefan w. GPLv3			
function up {
ups=""
for i in $(seq 1 $1)
do
        ups=$ups"../"
done
cd $ups
}
I concatenate a string, to allow to jump back with
Code:
cd -

Now I'm interested to hear, whether it will work in zsh, ksh, ash, csh, sh, dash and the like.

don't visit my homepage:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top