Move up multiple directories in bash
Posted by Kelvin on 04 Dec 2010 at 11:41 am | Tagged as: Ubuntu
Ever thought typing cd.. 5 times was silly? Try this up() function!
Add this to .bash_profile or .bashrc
up () { if [ -z $1 ]; then cd .. elif [ $1 -gt 0 ]; then let count=0 while [ $count -lt $1 ]; do cd .. let count=count+1 done else echo "Argument must be a positive integer." fi pwd }
The script in action:
kelvin:~/java/search/apache-solr-1.4.0/src/java/org/apache/solr/search$ up 5 kelvin:~/java/search/apache-solr-1.4.0/src$
- Introducing Bash-whacking
- Recursively delete .svn folders
- Move up multiple directories in bash
- Download youtube videos as mp3
- Useful ffmpeg commands
- Recursively copy only files with certain extension with rsync
- Recursive directory listing sorted by file size
- Download google video and youtube from command-line
- Reset wireless in Ubuntu 10.04 Lucid
- Delete files older than x days
- MD5 a directory recursively
- Convert fixed-width file to CSV
- Recursively find the n latest modified files in a directory
- Using sed to delete lines from a file
- Determine if a server supports Gzip compression
- Delete directories older than x days
- Mount a .dmg file in Ubuntu
- Batch convert svg to png in Ubuntu
- Split wav/flac/ape files with cue