<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: script not working in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-not-working/m-p/3205626#M167482</link>
    <description>I was able to make it work by  using the following:&lt;BR /&gt;&lt;BR /&gt;for i in spfctl.001.cfg.adhoc spfdat.001.cfg.adhoc&lt;BR /&gt;do&lt;BR /&gt;cat $i |sed s/$(date +%d%m)1/$SPFCHANGE/g &amp;gt;tmpfile&lt;BR /&gt;cp tmpfile $i&lt;BR /&gt;done&lt;BR /&gt;</description>
    <pubDate>Tue, 02 Mar 2004 13:07:45 GMT</pubDate>
    <dc:creator>Rory R Hammond</dc:creator>
    <dc:date>2004-03-02T13:07:45Z</dc:date>
    <item>
      <title>script not working</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-not-working/m-p/3205614#M167470</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;I am trying to use the sed command to change a file however am having difficulty because of some characters in the string I am trying to use - 'date +%d%m'1&lt;BR /&gt;&lt;BR /&gt;for i in spfctl.001.cfg.adhoc spfdat.001.cfg.adhoc&lt;BR /&gt; do&lt;BR /&gt;    cat $i |sed s/'date +%d%m'1/$SPFCHANGE/g &amp;gt;tmpfile&lt;BR /&gt;    cp tmpfile $i&lt;BR /&gt; done&lt;BR /&gt;    rm tmpfile&lt;BR /&gt;&lt;BR /&gt;    if [[ $? != 0 ]]&lt;BR /&gt; then&lt;BR /&gt;    echo "Failed to change the date, please check your syntax"&lt;BR /&gt;&lt;BR /&gt;can someone provide the correct syntax as I have tried numerous ways&lt;BR /&gt;&lt;BR /&gt;thnx&lt;BR /&gt;</description>
      <pubDate>Mon, 01 Mar 2004 07:49:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-not-working/m-p/3205614#M167470</guid>
      <dc:creator>lawrenzo</dc:creator>
      <dc:date>2004-03-01T07:49:36Z</dc:date>
    </item>
    <item>
      <title>Re: script not working</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-not-working/m-p/3205615#M167471</link>
      <description>Something like&lt;BR /&gt; &lt;BR /&gt;cat $i | sed "s/`date +%d%m`1/$SPFCHANGE/g" &amp;gt; tmpfile</description>
      <pubDate>Mon, 01 Mar 2004 07:55:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-not-working/m-p/3205615#M167471</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2004-03-01T07:55:22Z</dc:date>
    </item>
    <item>
      <title>Re: script not working</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-not-working/m-p/3205616#M167472</link>
      <description>Hi Lawrenzo,&lt;BR /&gt;&lt;BR /&gt;Look at your previous question on the same script where I mentioned that your 'sed' was not going to work and noted on how to fix it.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/que" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/que&lt;/A&gt;&lt;BR /&gt;stionanswer.do?threadId=471387&lt;BR /&gt;&lt;BR /&gt;//&lt;BR /&gt;'date +%d%m' inside sed will be treated as a string. &lt;BR /&gt;&lt;BR /&gt;cat $i |sed s/'date +%d%m'/$SPFCHANGE/g &amp;gt;tmpfile&lt;BR /&gt;&lt;BR /&gt;Modify the above as follows&lt;BR /&gt;&lt;BR /&gt;DATE=$(date +%d%m)&lt;BR /&gt;sed 's/'${DATE}'/'$SPFCHANGE'/g' $i &amp;gt; tmpfile&lt;BR /&gt;//&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Mon, 01 Mar 2004 10:14:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-not-working/m-p/3205616#M167472</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2004-03-01T10:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: script not working</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-not-working/m-p/3205617#M167473</link>
      <description>Hello Sri,&lt;BR /&gt;&lt;BR /&gt;I have attempted this however the file that I am trying to change the string in isn't happening.&lt;BR /&gt;&lt;BR /&gt;any other suggestions?&lt;BR /&gt;&lt;BR /&gt;Tnx</description>
      <pubDate>Mon, 01 Mar 2004 11:59:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-not-working/m-p/3205617#M167473</guid>
      <dc:creator>lawrenzo</dc:creator>
      <dc:date>2004-03-01T11:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: script not working</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-not-working/m-p/3205618#M167474</link>
      <description>Sridhar,&lt;BR /&gt; &lt;BR /&gt;Actually, on my system `date`is not treated as a string by "sed".  It does what you would hope :)&lt;BR /&gt; &lt;BR /&gt;Lawrenzo,&lt;BR /&gt; &lt;BR /&gt;If you remove the single quotes around your variabel and use Sridhars method it should work.&lt;BR /&gt; &lt;BR /&gt;i.e.&lt;BR /&gt; &lt;BR /&gt;$DATE=$(date +%d%m)1 # assuming that "1" isn't a typo&lt;BR /&gt;cat $i| sed "s/$DATE/$SPFCHANGE/g" &amp;gt; tmpfile&lt;BR /&gt; &lt;BR /&gt;</description>
      <pubDate>Mon, 01 Mar 2004 12:06:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-not-working/m-p/3205618#M167474</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2004-03-01T12:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: script not working</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-not-working/m-p/3205619#M167475</link>
      <description>Hi,&lt;BR /&gt;could you show us a few lines of input?&lt;BR /&gt; &lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
      <pubDate>Mon, 01 Mar 2004 12:08:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-not-working/m-p/3205619#M167475</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2004-03-01T12:08:52Z</dc:date>
    </item>
    <item>
      <title>Re: script not working</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-not-working/m-p/3205620#M167476</link>
      <description>Mark,&lt;BR /&gt;&lt;BR /&gt;I agree. But he was using quotes instead of backticks unlike you. So, I gave him DATE=$(...) answer in the other post.&lt;BR /&gt;&lt;BR /&gt;Lawrenzo,&lt;BR /&gt;&lt;BR /&gt;Can you post a sample of data?. I believe your input files do not contain the pattern given by date +%d%m command.&lt;BR /&gt;&lt;BR /&gt;-Sri&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 01 Mar 2004 12:11:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-not-working/m-p/3205620#M167476</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2004-03-01T12:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: script not working</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-not-working/m-p/3205621#M167477</link>
      <description>yes here is a couple of the lines, these appear about 10 times within the source file:&lt;BR /&gt;&lt;BR /&gt;TRANSFER_TYPE=send&lt;BR /&gt;LOCAL_FILEPATH=/sas/analysis/four/sigpack/util/data01/prod/sas_output/SIG`date +%d%m`1.dat&lt;BR /&gt;&lt;BR /&gt;REMOTE_FILEPATH=/data/cdirect/transit/prod_spf/SIG`date +%d%m`01.dat&lt;BR /&gt;&lt;BR /&gt;I know the second string here is `01 therefor the original for i in * will be run twice within the script unless there is another way?&lt;BR /&gt;&lt;BR /&gt;Thanks again</description>
      <pubDate>Mon, 01 Mar 2004 12:27:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-not-working/m-p/3205621#M167477</guid>
      <dc:creator>lawrenzo</dc:creator>
      <dc:date>2004-03-01T12:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: script not working</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-not-working/m-p/3205622#M167478</link>
      <description>Hi,&lt;BR /&gt;maybe I do not understand, but have you tried this:&lt;BR /&gt; sed s/'`date +%d%m`01'/$SPFCHANGE/g&lt;BR /&gt;or just&lt;BR /&gt; sed s/'`date +%d%m`'/$SPFCHANGE/g&lt;BR /&gt; &lt;BR /&gt;regards,&lt;BR /&gt;John K.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 01 Mar 2004 13:14:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-not-working/m-p/3205622#M167478</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2004-03-01T13:14:44Z</dc:date>
    </item>
    <item>
      <title>Re: script not working</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-not-working/m-p/3205623#M167479</link>
      <description>lawrenzo,&lt;BR /&gt; &lt;BR /&gt;There are about three answers here that will probably work,  have you actually tried them?  we haven't had any feedback from you.&lt;BR /&gt; &lt;BR /&gt;I would suggest cut &amp;amp; paste for the sed commands because the type of quote marks you use is important and not too easy to see in a web browser.</description>
      <pubDate>Mon, 01 Mar 2004 13:21:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-not-working/m-p/3205623#M167479</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2004-03-01T13:21:21Z</dc:date>
    </item>
    <item>
      <title>Re: script not working</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-not-working/m-p/3205624#M167480</link>
      <description>OK. Looking at your input data, I believe you are trying to *literally* change this string. Then try this.&lt;BR /&gt;&lt;BR /&gt;sed 's/\`date +%d%m\`1/'$SPFCHANGE'/g' data &amp;gt; tmpfile&lt;BR /&gt;&lt;BR /&gt;Escape (\) the backticks (`) and see if it works.&lt;BR /&gt;&lt;BR /&gt;As Mark said, copy and paste the code otherwise, you will get confused between back ticks and quotes.&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Mon, 01 Mar 2004 13:25:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-not-working/m-p/3205624#M167480</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2004-03-01T13:25:00Z</dc:date>
    </item>
    <item>
      <title>Re: script not working</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-not-working/m-p/3205625#M167481</link>
      <description>Hello All,&lt;BR /&gt;&lt;BR /&gt;Sorry for the late response,  I was away from my desk most of today,&lt;BR /&gt;&lt;BR /&gt;Thanks for the solutions, Mark and Sri's syntax both work&lt;BR /&gt;&lt;BR /&gt;many thanks&lt;BR /&gt;&lt;BR /&gt;Lawrenzo</description>
      <pubDate>Tue, 02 Mar 2004 02:55:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-not-working/m-p/3205625#M167481</guid>
      <dc:creator>lawrenzo</dc:creator>
      <dc:date>2004-03-02T02:55:31Z</dc:date>
    </item>
    <item>
      <title>Re: script not working</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-not-working/m-p/3205626#M167482</link>
      <description>I was able to make it work by  using the following:&lt;BR /&gt;&lt;BR /&gt;for i in spfctl.001.cfg.adhoc spfdat.001.cfg.adhoc&lt;BR /&gt;do&lt;BR /&gt;cat $i |sed s/$(date +%d%m)1/$SPFCHANGE/g &amp;gt;tmpfile&lt;BR /&gt;cp tmpfile $i&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Tue, 02 Mar 2004 13:07:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-not-working/m-p/3205626#M167482</guid>
      <dc:creator>Rory R Hammond</dc:creator>
      <dc:date>2004-03-02T13:07:45Z</dc:date>
    </item>
  </channel>
</rss>

