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...

Sunday, October 4, 2009

Add Hyperlink using jQuery

You can test this out in Firebug. Say you have a td element, <td id="foo" />,
you can add a link to this using jQuery:
jQuery("<a />").attr("href", "http://yahoo.com").appendTo("#foo").text("link to yahoo").after("<br />");