Introducing Bash-whacking
Posted by Kelvin on 04 Dec 2010 at 11:29 am | Tagged as: Ubuntu
Starting a new blog series on bash scripts you shouldn't live without.
Installation for scripts is simple: either add them to /usr/bin or add ~/bin to your bash path and place your scripts there. Don't forget to make the scripts executable!
Here's a complete example:
Suppose you wanted to create a script called foobar and make it accessible from anywhere.
First add create ~/bin, then add it to your bash path.
mkdir ~/bin gedit ~/.bash_profile
Add this to the end of the file:
export PATH=$PATH:~/bin
Now you need to enter a new bash shell for your settings to take effect (or logout and log back in).
Then, go ahead and create the script:
gedit ~/bin/foobar
Paste this in
echo "Foobar"
Save and exit, then make the script executable.
chmod +x ~/bin/foobar
Now from any directory, you can type foobar and get this back:
Foobar
- 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