<?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 1 or multiple spaces or tabs with a single space in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/replace-1-or-multiple-spaces-or-tabs-with-a-single-space/m-p/5019864#M96965</link>
    <description>&lt;!--!*#--&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;this will do it (it's [spaceTAB]):&lt;BR /&gt;sed '/s[ &lt;TAB&gt;][ &lt;TAB&gt;]*/ /g'&lt;BR /&gt;&lt;BR /&gt;Enter a real tab for &lt;TAB&gt;.&lt;BR /&gt;If you don not want to convert TAB(s) to space (like in your example), but to a single TAB, use - untested - &lt;BR /&gt;sed -e 's/  */ /g' -e 's/ *&lt;TAB&gt;&lt;TAB&gt;* */&lt;TAB&gt;/g' &lt;BR /&gt;&lt;BR /&gt;First is 'spacespace*', last is 'space*TABTABspace*'.&lt;BR /&gt;&lt;BR /&gt;mfG Peter&lt;/TAB&gt;&lt;/TAB&gt;&lt;/TAB&gt;&lt;/TAB&gt;&lt;/TAB&gt;&lt;/TAB&gt;</description>
    <pubDate>Wed, 20 Dec 2006 09:52:04 GMT</pubDate>
    <dc:creator>Peter Nikitka</dc:creator>
    <dc:date>2006-12-20T09:52:04Z</dc:date>
    <item>
      <title>Replace 1 or multiple spaces or tabs with a single space</title>
      <link>https://community.hpe.com/t5/operating-system-linux/replace-1-or-multiple-spaces-or-tabs-with-a-single-space/m-p/5019860#M96961</link>
      <description>Hi!&lt;BR /&gt;&lt;BR /&gt;First, I'm using standard POSIX Shell. Not Bash.&lt;BR /&gt;Additionnally, it's HP's standard sed also. Not GNU Sed.&lt;BR /&gt;&lt;BR /&gt;I'm trying to replace 1 or more spaces/tabs with a single on each occurrence.&lt;BR /&gt;&lt;BR /&gt;In Perl, I think it would be something like this:&lt;BR /&gt;&lt;BR /&gt;s/\s+/ /g&lt;BR /&gt;&lt;BR /&gt;'\s' being recognize has either a space or tab.&lt;BR /&gt;&lt;BR /&gt;I can't make it work with HPUX 11.11 or 11.23 sed. My script is already written in shell, so I was hopping not to go Perl.&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;&lt;BR /&gt;Patrick</description>
      <pubDate>Wed, 20 Dec 2006 09:40:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/replace-1-or-multiple-spaces-or-tabs-with-a-single-space/m-p/5019860#M96961</guid>
      <dc:creator>PatRoy</dc:creator>
      <dc:date>2006-12-20T09:40:37Z</dc:date>
    </item>
    <item>
      <title>Re: Replace 1 or multiple spaces or tabs with a single space</title>
      <link>https://community.hpe.com/t5/operating-system-linux/replace-1-or-multiple-spaces-or-tabs-with-a-single-space/m-p/5019861#M96962</link>
      <description>&lt;!--!*#--&gt;Hi Patrick:&lt;BR /&gt;&lt;BR /&gt;# echo "a   b   c"|tr -s [[:space:]] " "&lt;BR /&gt;&lt;BR /&gt;Of course, the Forum will probably lose the multiple spaces and tabs in this example!&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Wed, 20 Dec 2006 09:47:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/replace-1-or-multiple-spaces-or-tabs-with-a-single-space/m-p/5019861#M96962</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-12-20T09:47:52Z</dc:date>
    </item>
    <item>
      <title>Re: Replace 1 or multiple spaces or tabs with a single space</title>
      <link>https://community.hpe.com/t5/operating-system-linux/replace-1-or-multiple-spaces-or-tabs-with-a-single-space/m-p/5019862#M96963</link>
      <description>Hi Patrick,&lt;BR /&gt;&lt;BR /&gt;Try using tr instead.  &lt;BR /&gt;&lt;BR /&gt; tr -s [:space:] " " &lt;BR /&gt;&lt;BR /&gt;will do what you want.  To use tr you can do:&lt;BR /&gt;&lt;BR /&gt; tr -s [:space:] " " &amp;lt; testfile &lt;BR /&gt;&lt;BR /&gt;To get the output to a file:&lt;BR /&gt;&lt;BR /&gt; tr -s [:space:] " " &amp;lt; testfile &amp;gt; testfile.new&lt;BR /&gt;&lt;BR /&gt;you can also do:&lt;BR /&gt;&lt;BR /&gt;cat testfile |  tr -s [:space:] " " &amp;gt; testfile2&lt;BR /&gt;&lt;BR /&gt;You have all kinds of options.&lt;BR /&gt;</description>
      <pubDate>Wed, 20 Dec 2006 09:49:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/replace-1-or-multiple-spaces-or-tabs-with-a-single-space/m-p/5019862#M96963</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2006-12-20T09:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: Replace 1 or multiple spaces or tabs with a single space</title>
      <link>https://community.hpe.com/t5/operating-system-linux/replace-1-or-multiple-spaces-or-tabs-with-a-single-space/m-p/5019863#M96964</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Give 'tr -s ...' a try:&lt;BR /&gt;&lt;BR /&gt;$ tr -s " \t" " " &amp;lt; filein &amp;gt; fileout&lt;BR /&gt;&lt;BR /&gt;PCS</description>
      <pubDate>Wed, 20 Dec 2006 09:50:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/replace-1-or-multiple-spaces-or-tabs-with-a-single-space/m-p/5019863#M96964</guid>
      <dc:creator>spex</dc:creator>
      <dc:date>2006-12-20T09:50:17Z</dc:date>
    </item>
    <item>
      <title>Re: Replace 1 or multiple spaces or tabs with a single space</title>
      <link>https://community.hpe.com/t5/operating-system-linux/replace-1-or-multiple-spaces-or-tabs-with-a-single-space/m-p/5019864#M96965</link>
      <description>&lt;!--!*#--&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;this will do it (it's [spaceTAB]):&lt;BR /&gt;sed '/s[ &lt;TAB&gt;][ &lt;TAB&gt;]*/ /g'&lt;BR /&gt;&lt;BR /&gt;Enter a real tab for &lt;TAB&gt;.&lt;BR /&gt;If you don not want to convert TAB(s) to space (like in your example), but to a single TAB, use - untested - &lt;BR /&gt;sed -e 's/  */ /g' -e 's/ *&lt;TAB&gt;&lt;TAB&gt;* */&lt;TAB&gt;/g' &lt;BR /&gt;&lt;BR /&gt;First is 'spacespace*', last is 'space*TABTABspace*'.&lt;BR /&gt;&lt;BR /&gt;mfG Peter&lt;/TAB&gt;&lt;/TAB&gt;&lt;/TAB&gt;&lt;/TAB&gt;&lt;/TAB&gt;&lt;/TAB&gt;</description>
      <pubDate>Wed, 20 Dec 2006 09:52:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/replace-1-or-multiple-spaces-or-tabs-with-a-single-space/m-p/5019864#M96965</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2006-12-20T09:52:04Z</dc:date>
    </item>
    <item>
      <title>Re: Replace 1 or multiple spaces or tabs with a single space</title>
      <link>https://community.hpe.com/t5/operating-system-linux/replace-1-or-multiple-spaces-or-tabs-with-a-single-space/m-p/5019865#M96966</link>
      <description>Thanks James and others!&lt;BR /&gt;&lt;BR /&gt;tr -s [:space:] " "  didn't work for me. Had tried it like that, but doesn't do it.&lt;BR /&gt;&lt;BR /&gt;You somehow need 2 set of square brakets: [[:space:]]&lt;BR /&gt;&lt;BR /&gt;That did it.&lt;BR /&gt;Thanks again!</description>
      <pubDate>Wed, 20 Dec 2006 10:10:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/replace-1-or-multiple-spaces-or-tabs-with-a-single-space/m-p/5019865#M96966</guid>
      <dc:creator>PatRoy</dc:creator>
      <dc:date>2006-12-20T10:10:06Z</dc:date>
    </item>
    <item>
      <title>Re: Replace 1 or multiple spaces or tabs with a single space</title>
      <link>https://community.hpe.com/t5/operating-system-linux/replace-1-or-multiple-spaces-or-tabs-with-a-single-space/m-p/5019866#M96967</link>
      <description>Hi (again) Patrick:&lt;BR /&gt;&lt;BR /&gt;Please consider assigning points for the help you have been offered in this and your other threads as listed in your profile.&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 20 Dec 2006 10:24:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/replace-1-or-multiple-spaces-or-tabs-with-a-single-space/m-p/5019866#M96967</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-12-20T10:24:08Z</dc:date>
    </item>
  </channel>
</rss>

