<?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: replace words with spaces in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/replace-words-with-spaces/m-p/3582100#M703166</link>
    <description>Almost correct perl solution. Here's an alternative, and some remarks&lt;BR /&gt;&lt;BR /&gt;First, let's use autosplit (-aFpattern)&lt;BR /&gt;&lt;BR /&gt;lt09:/tmp 118 &amp;gt; cat xx.txt&lt;BR /&gt;S12|abc|123|456|111|999|ABRACA&lt;BR /&gt;lt09:/tmp 119 &amp;gt; perl -naF\\\| -e'$,="|";/^S/||next;$F[5]=" ";print@F' xx.txt&lt;BR /&gt;S12|abc|123|456|111| |ABRACA&lt;BR /&gt;lt09:/tmp 120 &amp;gt;&lt;BR /&gt;&lt;BR /&gt;Note that if the last field is empty, which in our case is not true: it contains a newline, split without additional arguments will drop them. You will have to add&lt;BR /&gt;&lt;BR /&gt;split /\|/, $_, -1&lt;BR /&gt;&lt;BR /&gt;to retain the empty trailing fields. -a does not need that, because the fields are split *before* the chomp happens:&lt;BR /&gt;&lt;BR /&gt;lt09:/tmp 126 &amp;gt; perl -naF\\\| -e'chomp;$,="|";/^S/||next;$F[5]=" ";print@F' yy.txt&lt;BR /&gt;S12|abc|123|456|111| |&lt;BR /&gt;lt09:/tmp 127 &amp;gt; perl -ne 'chomp;@arr=split(/\|/);$arr[5]=" ";$,="|";print @arr;' yy.txt&lt;BR /&gt;S12|abc|123|456|111| lt09:/tmp 128 &amp;gt;&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
    <pubDate>Thu, 14 Jul 2005 02:15:41 GMT</pubDate>
    <dc:creator>H.Merijn Brand (procura</dc:creator>
    <dc:date>2005-07-14T02:15:41Z</dc:date>
    <item>
      <title>replace words with spaces</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replace-words-with-spaces/m-p/3582095#M703161</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I have a file which contains lines with the following format:&lt;BR /&gt;&lt;BR /&gt;S12|abc|123|456|111|999|&lt;BR /&gt;&lt;BR /&gt;I need to replace the word or number which comes between 5th and 6th "|" (our case '999') with a space.&lt;BR /&gt;&lt;BR /&gt;It would be great if it can be done for lines that start with "S".&lt;BR /&gt;&lt;BR /&gt;Please help.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Pat&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 13 Jul 2005 18:15:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replace-words-with-spaces/m-p/3582095#M703161</guid>
      <dc:creator>Pat Peter</dc:creator>
      <dc:date>2005-07-13T18:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: replace words with spaces</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replace-words-with-spaces/m-p/3582096#M703162</link>
      <description>One way would be:&lt;BR /&gt;cat your_file | grep ^S | awk -F\|  '{printf("%s|%s|%s|%s|%s| |\n",$1,$2,$3,$4,$5)}'&lt;BR /&gt;&lt;BR /&gt;- Biswajit&lt;BR /&gt;</description>
      <pubDate>Wed, 13 Jul 2005 22:38:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replace-words-with-spaces/m-p/3582096#M703162</guid>
      <dc:creator>Biswajit Tripathy</dc:creator>
      <dc:date>2005-07-13T22:38:10Z</dc:date>
    </item>
    <item>
      <title>Re: replace words with spaces</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replace-words-with-spaces/m-p/3582097#M703163</link>
      <description>sed -e '/^S/s/\(.*\)|\(.*\)|\(.*\)|\(.*\)|\(.*\)|\(.*\)|\(.*\)/\1|\2|\3|\4|\5| |\6/g' filename</description>
      <pubDate>Wed, 13 Jul 2005 22:49:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replace-words-with-spaces/m-p/3582097#M703163</guid>
      <dc:creator>Vibhor Kumar Agarwal</dc:creator>
      <dc:date>2005-07-13T22:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: replace words with spaces</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replace-words-with-spaces/m-p/3582098#M703164</link>
      <description>You can do it as,&lt;BR /&gt;&lt;BR /&gt;echo "S12|abc|123|456|111|999|" | awk -F"|" '/^S/ { $6=" ";OFS="|";print $0 }'&lt;BR /&gt;&lt;BR /&gt;hth.</description>
      <pubDate>Wed, 13 Jul 2005 23:48:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replace-words-with-spaces/m-p/3582098#M703164</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-07-13T23:48:59Z</dc:date>
    </item>
    <item>
      <title>Re: replace words with spaces</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replace-words-with-spaces/m-p/3582099#M703165</link>
      <description>You can use perl as,&lt;BR /&gt;&lt;BR /&gt;echo "S12|abc|123|456|111|999|" | perl -ne ' @arr=split(/\|/);$arr[5]=" ";$,="|";print @arr;'&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;BR /&gt;perl -ne ' @arr=split(/\|/);$arr[5]=" ";$,="|";print @arr;' &lt;FILENAME&gt;&lt;BR /&gt;&lt;BR /&gt;hth.&lt;/FILENAME&gt;</description>
      <pubDate>Wed, 13 Jul 2005 23:58:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replace-words-with-spaces/m-p/3582099#M703165</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-07-13T23:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: replace words with spaces</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replace-words-with-spaces/m-p/3582100#M703166</link>
      <description>Almost correct perl solution. Here's an alternative, and some remarks&lt;BR /&gt;&lt;BR /&gt;First, let's use autosplit (-aFpattern)&lt;BR /&gt;&lt;BR /&gt;lt09:/tmp 118 &amp;gt; cat xx.txt&lt;BR /&gt;S12|abc|123|456|111|999|ABRACA&lt;BR /&gt;lt09:/tmp 119 &amp;gt; perl -naF\\\| -e'$,="|";/^S/||next;$F[5]=" ";print@F' xx.txt&lt;BR /&gt;S12|abc|123|456|111| |ABRACA&lt;BR /&gt;lt09:/tmp 120 &amp;gt;&lt;BR /&gt;&lt;BR /&gt;Note that if the last field is empty, which in our case is not true: it contains a newline, split without additional arguments will drop them. You will have to add&lt;BR /&gt;&lt;BR /&gt;split /\|/, $_, -1&lt;BR /&gt;&lt;BR /&gt;to retain the empty trailing fields. -a does not need that, because the fields are split *before* the chomp happens:&lt;BR /&gt;&lt;BR /&gt;lt09:/tmp 126 &amp;gt; perl -naF\\\| -e'chomp;$,="|";/^S/||next;$F[5]=" ";print@F' yy.txt&lt;BR /&gt;S12|abc|123|456|111| |&lt;BR /&gt;lt09:/tmp 127 &amp;gt; perl -ne 'chomp;@arr=split(/\|/);$arr[5]=" ";$,="|";print @arr;' yy.txt&lt;BR /&gt;S12|abc|123|456|111| lt09:/tmp 128 &amp;gt;&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Thu, 14 Jul 2005 02:15:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replace-words-with-spaces/m-p/3582100#M703166</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2005-07-14T02:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: replace words with spaces</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replace-words-with-spaces/m-p/3582101#M703167</link>
      <description>Even shorter, and retaining the lines that do not start with 'S':&lt;BR /&gt;&lt;BR /&gt;lt09:/tmp 131 &amp;gt; cat xx.txt&lt;BR /&gt;S12|abc|123|456|111|999|ABRACA&lt;BR /&gt;T12|abc|123|456|111|989|ABRACA&lt;BR /&gt;lt09:/tmp 132 &amp;gt; perl -naF\\\| -e'$,="|";/^S/and$F[5]=" ";print@F' xx.txt&lt;BR /&gt;S12|abc|123|456|111| |ABRACA&lt;BR /&gt;T12|abc|123|456|111|989|ABRACA&lt;BR /&gt;lt09:/tmp 133 &amp;gt;&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Thu, 14 Jul 2005 02:17:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replace-words-with-spaces/m-p/3582101#M703167</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2005-07-14T02:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: replace words with spaces</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replace-words-with-spaces/m-p/3582102#M703168</link>
      <description>Hi,&lt;BR /&gt;awk -F"|" '/^S/ {$6=" ";OFS="|";print} file&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Art</description>
      <pubDate>Fri, 15 Jul 2005 01:18:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replace-words-with-spaces/m-p/3582102#M703168</guid>
      <dc:creator>Arturo Galbiati</dc:creator>
      <dc:date>2005-07-15T01:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: replace words with spaces</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replace-words-with-spaces/m-p/3582103#M703169</link>
      <description>Pat,&lt;BR /&gt;&lt;BR /&gt;Here is a short one-liner using awk. It will replace the string between the 5th and 6th columns if there is a leading "S" in the first column of your input file or else it will print the entire record.&lt;BR /&gt;&lt;BR /&gt;# awk -F"|" '{if($1~/^S/){$6=" "; OFS="|"; print $0} else print $0}' input_file &amp;gt; output_file           &lt;BR /&gt;</description>
      <pubDate>Fri, 15 Jul 2005 10:14:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replace-words-with-spaces/m-p/3582103#M703169</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2005-07-15T10:14:12Z</dc:date>
    </item>
  </channel>
</rss>

