Docunext


Bash Functions Rock

October 10th, 2010

I've created my share of bash scripts and they are all well and good, but now that I've learned about bash functions, I'm definitely going to be writing more of them.

For example, I was interested in making a quick and easy way to switch my PATH settings to use either Ruby 1.8 or Ruby 1.9. To do so, I tried a bash script to modify a file my .bashrc file was sourcing. It worked, but I had to log out and log back in again.

By using a function I added to .bashrc, the shell remained the same, and the PATH environment variable could be changed.

Yearly Indexes: 2003 2004 2006 2007 2008 2009 2010 2011 2012 2013 2015 2019 2020 2022