<?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: SED help in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-help/m-p/3638253#M238752</link>
    <description># perl -pi -e'substr($_,10,10)=~s/( +)(?=\S)/"#"x length$1/ge' large_file&lt;BR /&gt;&lt;BR /&gt;I think, though by the time you want to go more complex, it might be better to write a real script&lt;BR /&gt;&lt;BR /&gt;There are two extra problems here:&lt;BR /&gt;&lt;BR /&gt;- if lines are shorter than 20 characters, you will get a warning like&lt;BR /&gt;&lt;BR /&gt;substr outside of string at -e line 1, &amp;lt;&amp;gt; line 1.&lt;BR /&gt;&lt;BR /&gt;- if you only check 10 chracters at offset 10, you don't look ahead to see if there are non-blanks after that character, and your defenition is not clear enough about when to change (IMHO)&lt;BR /&gt;&lt;BR /&gt;but you can safeguard that&lt;BR /&gt;&lt;BR /&gt;First decide, what to do if the line is shorter than 20 characters.&lt;BR /&gt;Then decide if the trailing non-space should be within the changed block, or if it is allowed in the trailing line&lt;BR /&gt;&lt;BR /&gt;IF you have NO trailing # signs in your document, the solution is even simpler&lt;BR /&gt;&lt;BR /&gt;# perl -pi -e'substr($_,10,10)=~y/ /#/;s/(#+)$/" "x length$1/e' large_file&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
    <pubDate>Fri, 30 Sep 2005 15:45:07 GMT</pubDate>
    <dc:creator>H.Merijn Brand (procura</dc:creator>
    <dc:date>2005-09-30T15:45:07Z</dc:date>
    <item>
      <title>SED help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-help/m-p/3638244#M238743</link>
      <description>How can I replace a space with a pound sign but only in columns 10-20 of a large text file?  For example: 's/ /#/g' will replace all occurrences, but I only want to replace occurrences in columns 10-20, but not 0-9 or 21-80.&lt;BR /&gt;&lt;BR /&gt;Thanks!</description>
      <pubDate>Thu, 29 Sep 2005 10:24:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-help/m-p/3638244#M238743</guid>
      <dc:creator>Bob Luce</dc:creator>
      <dc:date>2005-09-29T10:24:47Z</dc:date>
    </item>
    <item>
      <title>Re: SED help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-help/m-p/3638245#M238744</link>
      <description># perl -pi -e'substr($_,10,10)=~s/ /#/g' large_file&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Thu, 29 Sep 2005 10:33:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-help/m-p/3638245#M238744</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2005-09-29T10:33:26Z</dc:date>
    </item>
    <item>
      <title>Re: SED help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-help/m-p/3638246#M238745</link>
      <description>Hi Bob ,&lt;BR /&gt;&lt;BR /&gt;Considering you can split the columns using a filed delimeter ,&lt;BR /&gt;&lt;BR /&gt;example "|" (or can be any thing ) &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;cat infile |awk -F"|" '{print $1,$2,$3}' |while read a b c;do&lt;BR /&gt;echo "$a `echo $b|sed 's/ /#/g'` $c"&lt;BR /&gt;done &lt;BR /&gt;&lt;BR /&gt;Assuming the change need will be in the second column of awk o/p.&lt;BR /&gt;&lt;BR /&gt;I think you can manipulate this loop and achieve what you need.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;-BL.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 29 Sep 2005 10:38:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-help/m-p/3638246#M238745</guid>
      <dc:creator>baiju_3</dc:creator>
      <dc:date>2005-09-29T10:38:28Z</dc:date>
    </item>
    <item>
      <title>Re: SED help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-help/m-p/3638247#M238746</link>
      <description>I didnt have time to build an input file to test this but, try the following:&lt;BR /&gt;Note: the first paren grp has 9 chars so it is checking for a space in column 10, thes next line addresses a space in column 11 up to column 20.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;sed -e 's/\(.........\) \(.*\)/\1#\2/&lt;BR /&gt;s/\(..........\) \(.*\)/\1#\2/&lt;BR /&gt;s/\(...........\) \(.*\)/\1#\2/&lt;BR /&gt;s/\(............\) \(.*\)/\1#\2/&lt;BR /&gt;s/\(.............\) \(.*\)/\1#\2/&lt;BR /&gt;s/\(..............\) \(.*\)/\1#\2/&lt;BR /&gt;s/\(...............\) \(.*\)/\1#\2/&lt;BR /&gt;s/\(................\) \(.*\)/\1#\2/&lt;BR /&gt;s/\(.................\) \(.*\)/\1#\2/&lt;BR /&gt;s/\(..................\) \(.*\)/\1#\2/&lt;BR /&gt;s/\(...................\) \(.*\)/\1#\2/' &lt;INPUT /&gt;output</description>
      <pubDate>Thu, 29 Sep 2005 10:45:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-help/m-p/3638247#M238746</guid>
      <dc:creator>David DiBiase</dc:creator>
      <dc:date>2005-09-29T10:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: SED help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-help/m-p/3638248#M238747</link>
      <description>I don't sed can do that, but perl can-&lt;BR /&gt; &lt;BR /&gt;perl -p -e 'substr($_,10,10)=~s/ /#/g' yourfile&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Thu, 29 Sep 2005 10:47:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-help/m-p/3638248#M238747</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-09-29T10:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: SED help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-help/m-p/3638249#M238748</link>
      <description>Rodney, what did that add to my answer?&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Thu, 29 Sep 2005 10:51:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-help/m-p/3638249#M238748</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2005-09-29T10:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: SED help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-help/m-p/3638250#M238749</link>
      <description>one of these days I need to push aside my C and ksh stuff to learn more about perl :-)</description>
      <pubDate>Thu, 29 Sep 2005 10:51:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-help/m-p/3638250#M238749</guid>
      <dc:creator>David DiBiase</dc:creator>
      <dc:date>2005-09-29T10:51:49Z</dc:date>
    </item>
    <item>
      <title>Re: SED help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-help/m-p/3638251#M238750</link>
      <description>Procura,&lt;BR /&gt;&lt;BR /&gt;I didn't see your answer when I entered mine...&lt;BR /&gt;&lt;BR /&gt;Rod H</description>
      <pubDate>Thu, 29 Sep 2005 12:36:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-help/m-p/3638251#M238750</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-09-29T12:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: SED help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-help/m-p/3638252#M238751</link>
      <description>The perl command worked very well, thanks.  Unfortunately I forgot to mention one other part of my requirement - I am only looking for "embedded" spaces in my field, not "trailing" spaces.  For example, &lt;BR /&gt;"ABC   A   " should convert to&lt;BR /&gt;"ABC###A   ", not to&lt;BR /&gt;"ABC###A###".</description>
      <pubDate>Fri, 30 Sep 2005 13:25:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-help/m-p/3638252#M238751</guid>
      <dc:creator>Bob Luce</dc:creator>
      <dc:date>2005-09-30T13:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: SED help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-help/m-p/3638253#M238752</link>
      <description># perl -pi -e'substr($_,10,10)=~s/( +)(?=\S)/"#"x length$1/ge' large_file&lt;BR /&gt;&lt;BR /&gt;I think, though by the time you want to go more complex, it might be better to write a real script&lt;BR /&gt;&lt;BR /&gt;There are two extra problems here:&lt;BR /&gt;&lt;BR /&gt;- if lines are shorter than 20 characters, you will get a warning like&lt;BR /&gt;&lt;BR /&gt;substr outside of string at -e line 1, &amp;lt;&amp;gt; line 1.&lt;BR /&gt;&lt;BR /&gt;- if you only check 10 chracters at offset 10, you don't look ahead to see if there are non-blanks after that character, and your defenition is not clear enough about when to change (IMHO)&lt;BR /&gt;&lt;BR /&gt;but you can safeguard that&lt;BR /&gt;&lt;BR /&gt;First decide, what to do if the line is shorter than 20 characters.&lt;BR /&gt;Then decide if the trailing non-space should be within the changed block, or if it is allowed in the trailing line&lt;BR /&gt;&lt;BR /&gt;IF you have NO trailing # signs in your document, the solution is even simpler&lt;BR /&gt;&lt;BR /&gt;# perl -pi -e'substr($_,10,10)=~y/ /#/;s/(#+)$/" "x length$1/e' large_file&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Fri, 30 Sep 2005 15:45:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-help/m-p/3638253#M238752</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2005-09-30T15:45:07Z</dc:date>
    </item>
    <item>
      <title>Re: SED help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-help/m-p/3638254#M238753</link>
      <description>How about this perl one liner-&lt;BR /&gt;perl -p -e 'substr($_,10,10)=~s/ (?! *$)/#/g' largefile&lt;BR /&gt; &lt;BR /&gt;By using the (?! ) construct, the pattern match will replace spaces with # unless the rest of the text is all blanks within positions 10-20.&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Fri, 30 Sep 2005 16:29:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-help/m-p/3638254#M238753</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-09-30T16:29:56Z</dc:date>
    </item>
  </channel>
</rss>

