This entry is part 1 of 19 in the Bash-whacking series

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