Use shopt to reference bash paths as variables


/ Published in: Bash
Save to your folder(s)

Check out the bash command 'shopt -s cdable_vars' From the man bash page: If set, an argument to the cd builtin command that is not a directory is assumed to be the name of a variable whose value is the directory to change to.


Copy this code and paste it in your HTML
  1. # in .bash_profile or other suitable location
  2. shopt -s cdable_vars
  3. export ne="/etc/network/"
  4.  
  5. # in the shell
  6. source .bash_profile # (just this once, to reload the edited file)
  7. cd ne
  8. pwd # /etc/network/

URL: http://www.macosxhints.com/article.php?story=2005031814311425

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.