<div dir="ltr"><span style="font-family: courier new,monospace;">Afternoon,<br><br>I&#39;ve been trying to alter a sed one liner so it automatically picks up the current directory, instead of having to manually enter path information.<br>
<br>I hope the following is understandable.<br><br></span><span style="font-family: courier new,monospace;">1 $ pwd<br>
/demo_dir</span><span style="font-family: courier new,monospace;"><br><br>2 $ cat </span><span style="font-family: courier new,monospace;">TEST</span><br><span style="font-family: courier new,monospace;">
resources.file=/demo_dir</span><span style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;">/sub_dir</span><span style="font-family: courier new,monospace;">/resources.properties<br>
<br>3 $ sed &#39;s/\</span><span style="font-family: courier new,monospace;">/demo_dir</span><span style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;">/ROOT_DIR/g&#39; </span><span style="font-family: courier new,monospace;">TEST</span><span style="font-family: courier new,monospace;"> &gt; </span><span style="font-family: courier new,monospace;">TEST</span><br>
<span style="font-family: courier new,monospace;"><br>4 $ cat </span><span style="font-family: courier new,monospace;">TEST</span><br><span style="font-family: courier new,monospace;">
resources.file=</span><span style="font-family: courier new,monospace;">ROOT_DIR</span><span style="font-family: courier new,monospace;">/subdir/resources.properties</span><br><span style="font-family: courier new,monospace;"><br>
5 $ sed &#39;s/</span><span style="font-family: courier new,monospace;">ROOT_DIR</span><span style="font-family: courier new,monospace;">/</span><span style="font-family: courier new,monospace;">\/</span><span style="font-family: courier new,monospace;">demo_dir</span><span style="font-family: courier new,monospace;">/g&#39; </span><span style="font-family: courier new,monospace;">TEST</span><span style="font-family: courier new,monospace;"> &gt; </span><span style="font-family: courier new,monospace;">TEST</span><br>
<br>6<span style="font-family: courier new,monospace;"> $ cat </span><span style="font-family: courier new,monospace;">TEST</span><span style="font-family: courier new,monospace;"><br></span><span style="font-family: courier new,monospace;">
resources.file=</span><span style="font-family: courier new,monospace;">
/</span><span style="font-family: courier new,monospace;">demo_dir</span><span style="font-family: courier new,monospace;">/subdir/resources.properties</span><br><span style="font-family: courier new,monospace;"><br><br>
<br>I basically I run a version of what is show on line 3 prior to checking into source control and line 5 when I get the latest from source control. At the moment I can&#39;t get sed to correctly pick up an enviroment variable PWD or dynamically use the output of the pwd command.<br>
<br>As far as I&#39;m aware the following should do what I require but it won&#39;t work and the only example online I can find is changing the line endings, basically doing dos2unix in sed.<br></span><span style="font-family: courier new,monospace;"><br>
>From what I&#39;ve found out online the 2 lines bwloe should do what I require but I just can&#39;t get them working.<br><br>
$ sed &quot;s/`pwd`/ROOT_DIR/g&quot; TEST &gt; TEST</span><span style="font-family: courier new,monospace;"><br>
$ sed &quot;s/$PWD/ROOT_DIR/g&quot; TEST &gt; TEST</span><span style="font-family: courier new,monospace;"><br></span><span style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;"><br>

I&#39;ve been trying things in my spare time for about a week now but just
can&#39;t get any variation of using any of the following characters to
work. ` &#39; &quot; / \<br><br></span><span style="font-family: courier new,monospace;">Cheers for any assistance,<br></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">John</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"></div>