3 ms·
Simple bashrc function # go up X directories up_dir() { num_of_dirs=$1 for i in $(seq 1 $num_of_dirs) do cd ..
by jvehent 13y ago
Simple bashrc function
# go up X directories
up_dir() {
num_of_dirs=$1
for i in $(seq 1 $num_of_dirs)
do
cd ..
done
}
alias up=up_dir
Usage:
$ pwd
/home/user/svn/automation/puppet/trunk/modules/ossec/templates
$ up 4
$ pwd
/home/user/svn/automation/puppet
- dylnclrk 13y ago# Hah, I have almost the exact same thing in my bash_profile up () { TIMES=${1:-1}; for ((i=1; i<=$TIMES; i++)); do cd .. done } EDIT: Although now I'm looking at it and it looks like I made a strange choice with `TIMES=${1:-1};`. Oh well, I think it was my first bash script... it's funny to look back at the hack-y crap that your bash_profile accumulates over time.