<?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: awk or sed in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-or-sed/m-p/2804484#M82671</link>
    <description>This should work (being very specific here ..)&lt;BR /&gt;# sed 's/st_no,1,3/st_no,1,4/g' filename &amp;gt; filename.new&lt;BR /&gt;Do a quick for loop for say all files that has ".sql" extension.&lt;BR /&gt;# for i in `ls *.sql`&lt;BR /&gt;&amp;gt;do&lt;BR /&gt;&amp;gt;sed 's/st_no,1,3/st_no,1,4/g' $i &amp;gt; $i.new&lt;BR /&gt;&amp;gt;done&lt;BR /&gt;#&lt;BR /&gt;The *.sql.new files are the ones with the replaced string.&lt;BR /&gt;</description>
    <pubDate>Wed, 11 Sep 2002 17:37:12 GMT</pubDate>
    <dc:creator>S.K. Chan</dc:creator>
    <dc:date>2002-09-11T17:37:12Z</dc:date>
    <item>
      <title>awk or sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-or-sed/m-p/2804482#M82669</link>
      <description>HI masters,&lt;BR /&gt;     I have number of pro*c and .sql file which contain,&lt;BR /&gt; substr(a.st_no,1,3) OR substr(st_no,1,3).&lt;BR /&gt;&lt;BR /&gt;I want to change it to,&lt;BR /&gt; substr(a.st_no,1,4) OR substr(st_no,1,4). &lt;BR /&gt;&lt;BR /&gt;  How can i do this using awk or sed?&lt;BR /&gt;Thanks in adv.&lt;BR /&gt;(Pts. will be given to each response.)&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 11 Sep 2002 17:28:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-or-sed/m-p/2804482#M82669</guid>
      <dc:creator>NS_2</dc:creator>
      <dc:date>2002-09-11T17:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: awk or sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-or-sed/m-p/2804483#M82670</link>
      <description>Hi&lt;BR /&gt;I think sed is best for this.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;sed 's/substr(a.st_no,1,3)/substr(a.st_no,1,4)/' file1 &amp;gt;file2</description>
      <pubDate>Wed, 11 Sep 2002 17:35:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-or-sed/m-p/2804483#M82670</guid>
      <dc:creator>Leif Halvarsson_2</dc:creator>
      <dc:date>2002-09-11T17:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: awk or sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-or-sed/m-p/2804484#M82671</link>
      <description>This should work (being very specific here ..)&lt;BR /&gt;# sed 's/st_no,1,3/st_no,1,4/g' filename &amp;gt; filename.new&lt;BR /&gt;Do a quick for loop for say all files that has ".sql" extension.&lt;BR /&gt;# for i in `ls *.sql`&lt;BR /&gt;&amp;gt;do&lt;BR /&gt;&amp;gt;sed 's/st_no,1,3/st_no,1,4/g' $i &amp;gt; $i.new&lt;BR /&gt;&amp;gt;done&lt;BR /&gt;#&lt;BR /&gt;The *.sql.new files are the ones with the replaced string.&lt;BR /&gt;</description>
      <pubDate>Wed, 11 Sep 2002 17:37:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-or-sed/m-p/2804484#M82671</guid>
      <dc:creator>S.K. Chan</dc:creator>
      <dc:date>2002-09-11T17:37:12Z</dc:date>
    </item>
    <item>
      <title>Re: awk or sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-or-sed/m-p/2804485#M82672</link>
      <description>Nasty, but what the hell:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;find PATHWHEREFILESLIVE -type f -name "*.sql" -exec grep -l -e "substr(a.st_no,1,3)" -e "subs&lt;BR /&gt;tr(st_no,1,3)" {} \; |&lt;BR /&gt;awk '{printf("sed -e \"s/substr\(a.st_no,1,3\)/substr\(a.st_no,1,4\)/\" -e \"s/s&lt;BR /&gt;ubstr\(st_no,1,3\)/substr\(st_no,1,4\)/\" %s &amp;gt; %s.dummy; mv %s.dummy %s\n", $1, $1,&lt;BR /&gt; $1, $1); }' |xargs -i sh {}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;BUT PLEASE make SURE YOU BACKUP your files FIRST!!!!!!!!!&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Wed, 11 Sep 2002 18:37:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-or-sed/m-p/2804485#M82672</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-09-11T18:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: awk or sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-or-sed/m-p/2804486#M82673</link>
      <description>Well, just in case you might consider perl...&lt;BR /&gt;&lt;BR /&gt;perl -i -ne 's/st_no,1,3\)/st_no,1,4\)/g;print' yourfile&lt;BR /&gt;&lt;BR /&gt;Note that this (-i option) will edit IN PLACE, overwriting your original files with the changes. To preserve your old files, save a copy, or use:&lt;BR /&gt;&lt;BR /&gt;perl -i.bak -ne 's/st_no,1,3\)/st_no,1,4\)/g;print' yourfile&lt;BR /&gt;&lt;BR /&gt;to keep copies with *.bak name.&lt;BR /&gt;&lt;BR /&gt;Tom</description>
      <pubDate>Wed, 11 Sep 2002 18:53:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-or-sed/m-p/2804486#M82673</guid>
      <dc:creator>Tom Maloy</dc:creator>
      <dc:date>2002-09-11T18:53:25Z</dc:date>
    </item>
  </channel>
</rss>

