AWG Blogs

Saturday, October 17, 2009

Change Directory with String Replacement

Found out through experimentation how to change directories in the bash shell using sed string replacement. I need a quick way to switch from production to staging sites which have the same path but for the user home directory.

First I tried:

echo `pwd` | echo `sed -e 's/production/staging/' ` | cd

That didn't work.

Then I tried:

cd $(echo `pwd` | echo `sed -e 's/production/staging/' ` )

That worked. Go figure...

No comments:

Post a Comment