Skip to content

Instantly share code, notes, and snippets.

@oss6
Created January 12, 2015 23:18
Show Gist options
  • Save oss6/40a29edd5b66629e69f9 to your computer and use it in GitHub Desktop.
Save oss6/40a29edd5b66629e69f9 to your computer and use it in GitHub Desktop.
Shell function to easily go up through the directory tree without all those dots (cd ../../../../ ---> up 4)
#!/bin/bash
function up() {
if [ $# -ne 1 ]
then
echo "You must provide one argument. e.g. 'up 4'"
fi
START=1
END=$1
for (( i=$START; i<=$END; i++ ))
do
cd ../
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment