<?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: Removing spaces between lines in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/removing-spaces-between-lines/m-p/4127114#M315682</link>
    <description>There is a command to do that: rmnl(1)</description>
    <pubDate>Fri, 11 Jan 2008 08:59:43 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2008-01-11T08:59:43Z</dc:date>
    <item>
      <title>Removing spaces between lines</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/removing-spaces-between-lines/m-p/4127106#M315674</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;I am having one file say abc.txt. File has two fields.Entries of files :&lt;BR /&gt;&lt;BR /&gt;Prefix      description&lt;BR /&gt;&lt;BR /&gt;"202xxxx"  This is hhhhh tatat.&lt;BR /&gt;&lt;BR /&gt;"303nnnnn" This is 2nd line.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;"606hhhh" This is 3rd line.&lt;BR /&gt;......&lt;BR /&gt;.... and so on.&lt;BR /&gt;&lt;BR /&gt;Between two lines many blank lines are there. I want to remove all blank line.&lt;BR /&gt;Logic i have written is:&lt;BR /&gt;&lt;BR /&gt;Code:&lt;BR /&gt;****************************************&lt;BR /&gt;var1=`wc -l abc.txt.txt | cut -f1 -d' '`&lt;BR /&gt;&lt;BR /&gt;#This will take total no of lines in file.&lt;BR /&gt;&lt;BR /&gt;count=1&lt;BR /&gt;while read line&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;length=`echo $line | wc -w`&lt;BR /&gt;if [ $length -eq 0 ]; then&lt;BR /&gt;echo " NULL LINE "&lt;BR /&gt;else&lt;BR /&gt;`echo $line &amp;gt;&amp;gt; abc_final.txt`&lt;BR /&gt;fi;&lt;BR /&gt;if [ $count -eq $var ]; then&lt;BR /&gt;   echo " Breaking loop "&lt;BR /&gt;       break;&lt;BR /&gt;   fi;&lt;BR /&gt;   count=`expr $count + 1`&lt;BR /&gt;done &amp;lt; abc.txt&lt;BR /&gt;&lt;BR /&gt;******************************************&lt;BR /&gt;Can some one suggest any simple and effective way to acieve this?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 10 Jan 2008 09:40:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/removing-spaces-between-lines/m-p/4127106#M315674</guid>
      <dc:creator>N Gopal</dc:creator>
      <dc:date>2008-01-10T09:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: Removing spaces between lines</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/removing-spaces-between-lines/m-p/4127107#M315675</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;You can use awk to achieve this:&lt;BR /&gt;&lt;BR /&gt;cat abc.txt | awk '$0!~/^$/ {print $0}' &amp;gt; abc.txt.new&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;&lt;BR /&gt;Richard</description>
      <pubDate>Thu, 10 Jan 2008 10:01:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/removing-spaces-between-lines/m-p/4127107#M315675</guid>
      <dc:creator>Richard Hepworth</dc:creator>
      <dc:date>2008-01-10T10:01:22Z</dc:date>
    </item>
    <item>
      <title>Re: Removing spaces between lines</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/removing-spaces-between-lines/m-p/4127108#M315676</link>
      <description>Hey&lt;BR /&gt;&lt;BR /&gt;Check this from &lt;A href="http://sed.sourceforge.net/sed1line.txt:" target="_blank"&gt;http://sed.sourceforge.net/sed1line.txt:&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt; # delete ALL blank lines from a file (same as "grep '.' ")&lt;BR /&gt; sed '/^$/d'                           # method 1&lt;BR /&gt; sed '/./!d'                           # method 2&lt;BR /&gt;&lt;BR /&gt;example:&lt;BR /&gt;$sed '/./!d' yourfile &amp;gt;&amp;gt; newfile&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 10 Jan 2008 10:06:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/removing-spaces-between-lines/m-p/4127108#M315676</guid>
      <dc:creator>Oviwan</dc:creator>
      <dc:date>2008-01-10T10:06:00Z</dc:date>
    </item>
    <item>
      <title>Re: Removing spaces between lines</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/removing-spaces-between-lines/m-p/4127109#M315677</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;grep -v "^$" abc.txt &amp;gt;newfile&lt;BR /&gt;&lt;BR /&gt;would also be possible.&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
      <pubDate>Thu, 10 Jan 2008 10:07:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/removing-spaces-between-lines/m-p/4127109#M315677</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2008-01-10T10:07:23Z</dc:date>
    </item>
    <item>
      <title>Re: Removing spaces between lines</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/removing-spaces-between-lines/m-p/4127110#M315678</link>
      <description>Hi Gopal,&lt;BR /&gt;&lt;BR /&gt;Simply do sed '/^$/d' abc.txt &amp;gt; def.txt that should suffice.&lt;BR /&gt;&lt;BR /&gt;where abc.txt will have quiet few new lines in it, like&lt;BR /&gt;abc&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;qasd&lt;BR /&gt;&lt;BR /&gt;sd&lt;BR /&gt;EOF&lt;BR /&gt;&lt;BR /&gt;def.txt will be &lt;BR /&gt;abc&lt;BR /&gt;qasd&lt;BR /&gt;sd&lt;BR /&gt;EOF&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Srikanth</description>
      <pubDate>Thu, 10 Jan 2008 11:21:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/removing-spaces-between-lines/m-p/4127110#M315678</guid>
      <dc:creator>Srikanth Arunachalam</dc:creator>
      <dc:date>2008-01-10T11:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: Removing spaces between lines</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/removing-spaces-between-lines/m-p/4127111#M315679</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;The problem with reqular expressions like:&lt;BR /&gt;&lt;BR /&gt;/^$/&lt;BR /&gt;&lt;BR /&gt;...is that this assumes that a "blank" line consists only of a newline character without any intervening spaces and/or tabs.&lt;BR /&gt;&lt;BR /&gt;If you wish to use 'sed':&lt;BR /&gt;&lt;BR /&gt;# sed '/^[     ]*$/d' file&lt;BR /&gt;&lt;BR /&gt;...where the expression in brackets consists of a space followed by a tab character, will work.  Some 'sed' variations (but not HP's) allow a '\t' in lieu of typing the actual TAB.&lt;BR /&gt;&lt;BR /&gt;Otherwise, I prefer:&lt;BR /&gt;&lt;BR /&gt;# perl -ne 'print unless /^\s*$/' file&lt;BR /&gt;&lt;BR /&gt;The '\s' represents "whitespace" which is defined to include both spaces and tabs.  Hence if a line consists of zero or more characters of whitespace only, it is skipped.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 10 Jan 2008 13:02:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/removing-spaces-between-lines/m-p/4127111#M315679</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-01-10T13:02:41Z</dc:date>
    </item>
    <item>
      <title>Re: Removing spaces between lines</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/removing-spaces-between-lines/m-p/4127112#M315680</link>
      <description>Try the ex(1) construct below:&lt;BR /&gt;&lt;BR /&gt;ex -s file &amp;lt;&lt;EOF&gt;&lt;/EOF&gt;g/^$/d&lt;BR /&gt;x&lt;BR /&gt;EOF</description>
      <pubDate>Thu, 10 Jan 2008 20:13:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/removing-spaces-between-lines/m-p/4127112#M315680</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2008-01-10T20:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: Removing spaces between lines</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/removing-spaces-between-lines/m-p/4127113#M315681</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;Appologies for very delay in responding.&lt;BR /&gt;&lt;BR /&gt;Both solutions given by James is working for me. I am choosing perl out of that.&lt;BR /&gt;&lt;BR /&gt;Thanks a lot to all for their replies.&lt;BR /&gt;&lt;BR /&gt;Regards</description>
      <pubDate>Fri, 11 Jan 2008 06:42:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/removing-spaces-between-lines/m-p/4127113#M315681</guid>
      <dc:creator>N Gopal</dc:creator>
      <dc:date>2008-01-11T06:42:17Z</dc:date>
    </item>
    <item>
      <title>Re: Removing spaces between lines</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/removing-spaces-between-lines/m-p/4127114#M315682</link>
      <description>There is a command to do that: rmnl(1)</description>
      <pubDate>Fri, 11 Jan 2008 08:59:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/removing-spaces-between-lines/m-p/4127114#M315682</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-01-11T08:59:43Z</dc:date>
    </item>
    <item>
      <title>Re: Removing spaces between lines</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/removing-spaces-between-lines/m-p/4127115#M315683</link>
      <description>The simplest way is to use ssp and rmnl (check the man pages). rmnl removes all blank lines except those at the front of the file. ssp removes the blanks lines at the front and then reduces all subsequent blank lines to just one. This will remove all your blank lines:&lt;BR /&gt; &lt;BR /&gt;cat $MYFILE | ssp | rmnl &amp;gt;&amp;gt; abc_final.txt&lt;BR /&gt; &lt;BR /&gt;Note that if the incoming file is badly formatted with space-filled lines (which look blank but actually have blank characters) then additional steps will be needed to remove those 'looks-blank' lines.</description>
      <pubDate>Fri, 11 Jan 2008 12:24:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/removing-spaces-between-lines/m-p/4127115#M315683</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2008-01-11T12:24:32Z</dc:date>
    </item>
  </channel>
</rss>

