<?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: Single white space replacement whilst ignoring multiple spaces in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/single-white-space-replacement-whilst-ignoring-multiple-spaces/m-p/4713403#M660091</link>
    <description>&lt;!--!*#--&gt;Perhaps:&lt;BR /&gt;&lt;BR /&gt;$ echo '12   3 4  5 6' | \&lt;BR /&gt; sed -e 's/\([^ ]\) \([^ ]\)/\1\2/g'&lt;BR /&gt;12   34  56&lt;BR /&gt;&lt;BR /&gt;(Replace non-space1+space+non-space2 with&lt;BR /&gt;non-space1+non-space2 everywhere.)</description>
    <pubDate>Mon, 15 Nov 2010 15:08:22 GMT</pubDate>
    <dc:creator>Steven Schweda</dc:creator>
    <dc:date>2010-11-15T15:08:22Z</dc:date>
    <item>
      <title>Single white space replacement whilst ignoring multiple spaces</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/single-white-space-replacement-whilst-ignoring-multiple-spaces/m-p/4713402#M660090</link>
      <description>&lt;!--!*#--&gt;Hi&lt;BR /&gt;does anyone know how to replace a single white space and leave and multiple spaces alone....&lt;BR /&gt;so, for example:&lt;BR /&gt;&lt;BR /&gt;echo "12   3 4  5 6"&lt;BR /&gt;&lt;BR /&gt;should produce &lt;BR /&gt;&lt;BR /&gt;12   34  56&lt;BR /&gt;&lt;BR /&gt;(where the only single spaces were between 3 &amp;amp;4 and 5&amp;amp; )&lt;BR /&gt;&lt;BR /&gt;awk/sed  or perl is fine thks - preferable in one line - thks&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 15 Nov 2010 13:47:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/single-white-space-replacement-whilst-ignoring-multiple-spaces/m-p/4713402#M660090</guid>
      <dc:creator>eric lipede_1</dc:creator>
      <dc:date>2010-11-15T13:47:36Z</dc:date>
    </item>
    <item>
      <title>Re: Single white space replacement whilst ignoring multiple spaces</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/single-white-space-replacement-whilst-ignoring-multiple-spaces/m-p/4713403#M660091</link>
      <description>&lt;!--!*#--&gt;Perhaps:&lt;BR /&gt;&lt;BR /&gt;$ echo '12   3 4  5 6' | \&lt;BR /&gt; sed -e 's/\([^ ]\) \([^ ]\)/\1\2/g'&lt;BR /&gt;12   34  56&lt;BR /&gt;&lt;BR /&gt;(Replace non-space1+space+non-space2 with&lt;BR /&gt;non-space1+non-space2 everywhere.)</description>
      <pubDate>Mon, 15 Nov 2010 15:08:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/single-white-space-replacement-whilst-ignoring-multiple-spaces/m-p/4713403#M660091</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2010-11-15T15:08:22Z</dc:date>
    </item>
    <item>
      <title>Re: Single white space replacement whilst ignoring multiple spaces</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/single-white-space-replacement-whilst-ignoring-multiple-spaces/m-p/4713404#M660092</link>
      <description>Hi Eric:&lt;BR /&gt;&lt;BR /&gt;A bit late, but in Perl:&lt;BR /&gt;&lt;BR /&gt;echo "12  3 4  5 6"|perl -ple 's/(\S)\s(\S)/$1$2/g'&lt;BR /&gt;12  34  56&lt;BR /&gt;&lt;BR /&gt;The '\s' is a whitespace (space, tab) character whereas the '\S' is a non-whitespace character.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 15 Nov 2010 16:06:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/single-white-space-replacement-whilst-ignoring-multiple-spaces/m-p/4713404#M660092</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-11-15T16:06:00Z</dc:date>
    </item>
    <item>
      <title>Re: Single white space replacement whilst ignoring multiple spaces</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/single-white-space-replacement-whilst-ignoring-multiple-spaces/m-p/4713405#M660093</link>
      <description>&lt;!--!*#--&gt;IMHO this would be an excellent example for using the \b 'boundary' matching in perl's regulare expression:&lt;BR /&gt;&lt;BR /&gt;# echo "12  3 4 5  6"|perl -ple 's/\b\s\b//g'&lt;BR /&gt;12  345  6&lt;BR /&gt;&lt;BR /&gt;(12ss3s4s5ss6)&lt;BR /&gt;&lt;BR /&gt;Please observe how this replaced ALL single-white-space instances. &lt;BR /&gt;&lt;BR /&gt;JRF's solution, would replace the single space between 3 and 4, but would NOT replace the single space between 4 and 5 for the example I used, as the match engine has already dealt with '4'.&lt;BR /&gt;&lt;BR /&gt;You have to decide what is 'right' for your usage. I happen to think the using \b is more  true to the original problem statement.&lt;BR /&gt;&lt;BR /&gt;fwiw,&lt;BR /&gt;Hein&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;# echo "12  3 4 5  6"|perl -ple 's/(\S)\s(\S)/$1$2/g'&lt;BR /&gt;12  34 5  6&lt;BR /&gt;</description>
      <pubDate>Mon, 15 Nov 2010 19:46:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/single-white-space-replacement-whilst-ignoring-multiple-spaces/m-p/4713405#M660093</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2010-11-15T19:46:44Z</dc:date>
    </item>
    <item>
      <title>Re: Single white space replacement whilst ignoring multiple spaces</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/single-white-space-replacement-whilst-ignoring-multiple-spaces/m-p/4713406#M660094</link>
      <description>Thks to all of you.&lt;BR /&gt;&lt;BR /&gt;Hein, I think your solution was the most robust</description>
      <pubDate>Tue, 16 Nov 2010 02:54:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/single-white-space-replacement-whilst-ignoring-multiple-spaces/m-p/4713406#M660094</guid>
      <dc:creator>eric lipede_1</dc:creator>
      <dc:date>2010-11-16T02:54:44Z</dc:date>
    </item>
    <item>
      <title>Re: Single white space replacement whilst ignoring multiple spaces</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/single-white-space-replacement-whilst-ignoring-multiple-spaces/m-p/4713407#M660095</link>
      <description>&lt;!--!*#--&gt;&amp;gt;Hein: JRF's solution, would replace the single space between 3 and 4, but would NOT replace the single space between 4 and 5 for the example I used&lt;BR /&gt;&lt;BR /&gt;It seems Steven's fails the same way.  But one solution is simple, do it again:&lt;BR /&gt;echo '12   3 4 4  5 6' |  sed -e 's/\([^ ]\) \([^ ]\)/\1\2/g' -e 's/\([^ ]\) \([^ ]\)/\1\2/g'</description>
      <pubDate>Wed, 17 Nov 2010 03:57:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/single-white-space-replacement-whilst-ignoring-multiple-spaces/m-p/4713407#M660095</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2010-11-17T03:57:43Z</dc:date>
    </item>
    <item>
      <title>Re: Single white space replacement whilst ignoring multiple spaces</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/single-white-space-replacement-whilst-ignoring-multiple-spaces/m-p/4713408#M660096</link>
      <description>I re-opened this thread as I think that this is an interesting problem ...and of course to assign points to great answers....</description>
      <pubDate>Wed, 17 Nov 2010 04:12:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/single-white-space-replacement-whilst-ignoring-multiple-spaces/m-p/4713408#M660096</guid>
      <dc:creator>eric lipede_1</dc:creator>
      <dc:date>2010-11-17T04:12:33Z</dc:date>
    </item>
    <item>
      <title>Re: Single white space replacement whilst ignoring multiple spaces</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/single-white-space-replacement-whilst-ignoring-multiple-spaces/m-p/4713409#M660097</link>
      <description>&lt;!--!*#--&gt;Hi (again) Eriic:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; I re-opened this thread as I think that this is an interesting problem ...&lt;BR /&gt;&lt;BR /&gt;From a Perl perspective, I think Hein provided the most general, most direct solution.  It works for the original cases as well as Dennis's sample data.&lt;BR /&gt;&lt;BR /&gt;Dennis does offer an interesting solution, though.  My original offering of:&lt;BR /&gt;&lt;BR /&gt;# perl -ple 's/(\S)\s(\S)/$1$2/g'&lt;BR /&gt;&lt;BR /&gt;...could be modified to perform the repetitive substitutions of Dennis's 'sed' by writing:&lt;BR /&gt;&lt;BR /&gt;# echo "12   3 4 4  5 6"|perl -ple '1 while s/(\S)\s(\S)/$1$2/g'&lt;BR /&gt;12   344  56&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 17 Nov 2010 12:24:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/single-white-space-replacement-whilst-ignoring-multiple-spaces/m-p/4713409#M660097</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-11-17T12:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: Single white space replacement whilst ignoring multiple spaces</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/single-white-space-replacement-whilst-ignoring-multiple-spaces/m-p/4713410#M660098</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;Ive tested it with more variations of the sample data...and files . Both remove white spaces and ignore multiple instances of them -thks!</description>
      <pubDate>Wed, 17 Nov 2010 13:02:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/single-white-space-replacement-whilst-ignoring-multiple-spaces/m-p/4713410#M660098</guid>
      <dc:creator>eric lipede_1</dc:creator>
      <dc:date>2010-11-17T13:02:30Z</dc:date>
    </item>
  </channel>
</rss>

