Contents of gaurav.txt file

$generalNetPath = "/net";
$generalNetPath = "/glbusers4/glb/aimsys/apxwrk48";

I trying to replace /glbusers4/glb/aimsys/apxwrk48 by pwd as follows

sed '/apxwrk/c\$generalNetPath = "$qaz";' gaurav.txt

I am getting the output as

$generalNetPath = "/net";
$generalNetPath = "$qaz";

I was expecting $qaz be replaced by my present working directory.As far as my knowledge this is happening because of ' (single quotes) that I am using.I have tried using \ before " but that didn't help.Is there any anyway can I do this.I mean can I use anything other than ' so that I can have value of $pwd replaced by using any character other than ' .I tried using | but didn't work.Please help me out with this.

  • Note that in POSIX shells, the current working directory is in the $PWD variable. Commented Feb 15, 2013 at 17:41

1 Answer 1


I figured it out myself.Here is the syntax.Thanks anyway.

sed "/apxwrk/c\$generalNetPath = \"$qaz\";" gaurav.txt
  • Yes or you could also use single quotes on the inside, which would work better in some circumstances (and worse only in the circumstance that your working directory name includes single quotes).
    – dubiousjim
    Commented Jan 11, 2013 at 13:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .