<?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: read complete lines in a for loop in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/read-complete-lines-in-a-for-loop/m-p/2741118#M946830</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Here's another method (takes care of spaces and tabs):&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;inc=1&lt;BR /&gt;total=`cat $1 | wc -l`&lt;BR /&gt;&lt;BR /&gt;while [ "$inc" -le "$total" ]&lt;BR /&gt;do&lt;BR /&gt;  tail -$inc $1 | head -1&lt;BR /&gt;  inc=`expr $inc + 1`&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards.&lt;BR /&gt;&lt;BR /&gt;Steven Sim Kok Leong</description>
    <pubDate>Mon, 10 Jun 2002 14:39:43 GMT</pubDate>
    <dc:creator>Steven Sim Kok Leong</dc:creator>
    <dc:date>2002-06-10T14:39:43Z</dc:date>
    <item>
      <title>read complete lines in a for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/read-complete-lines-in-a-for-loop/m-p/2741112#M946824</link>
      <description>hi all!&lt;BR /&gt;&lt;BR /&gt;Can anyone help me out here, I need to read completes Lines of a File in a for loop.&lt;BR /&gt;for i in //filename//&lt;BR /&gt;and i is supposed to be the first, second etc. line of that file.&lt;BR /&gt;&lt;BR /&gt;Anyone got an Idea how I could do that ? &lt;BR /&gt;&lt;BR /&gt;kind regards&lt;BR /&gt;Oliver</description>
      <pubDate>Mon, 10 Jun 2002 12:53:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/read-complete-lines-in-a-for-loop/m-p/2741112#M946824</guid>
      <dc:creator>Oliver Charni</dc:creator>
      <dc:date>2002-06-10T12:53:16Z</dc:date>
    </item>
    <item>
      <title>Re: read complete lines in a for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/read-complete-lines-in-a-for-loop/m-p/2741113#M946825</link>
      <description>for i in $(cat filename)&lt;BR /&gt;do&lt;BR /&gt;echo $i&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Later,&lt;BR /&gt;Bill</description>
      <pubDate>Mon, 10 Jun 2002 12:54:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/read-complete-lines-in-a-for-loop/m-p/2741113#M946825</guid>
      <dc:creator>Bill McNAMARA_1</dc:creator>
      <dc:date>2002-06-10T12:54:49Z</dc:date>
    </item>
    <item>
      <title>Re: read complete lines in a for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/read-complete-lines-in-a-for-loop/m-p/2741114#M946826</link>
      <description>Hi Oliver,&lt;BR /&gt;&lt;BR /&gt;I prefer a while loop:&lt;BR /&gt;&lt;BR /&gt;while read line&lt;BR /&gt;do&lt;BR /&gt;   echo "$line"&lt;BR /&gt;done &lt;FILENAME&gt;&lt;/FILENAME&gt;&lt;BR /&gt;Quoting $line maintains spacing.&lt;BR /&gt;&lt;BR /&gt;Darrell</description>
      <pubDate>Mon, 10 Jun 2002 13:04:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/read-complete-lines-in-a-for-loop/m-p/2741114#M946826</guid>
      <dc:creator>Darrell Allen</dc:creator>
      <dc:date>2002-06-10T13:04:02Z</dc:date>
    </item>
    <item>
      <title>Re: read complete lines in a for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/read-complete-lines-in-a-for-loop/m-p/2741115#M946827</link>
      <description>Hi Oliver,&lt;BR /&gt;&lt;BR /&gt;You must beware with the spaces or tabs character into the file, this is because the for structure takes this as a separator.&lt;BR /&gt;&lt;BR /&gt;If you have spaces in your file you must replace (use sed) by a different character in order to use the whole line as one parameter.&lt;BR /&gt;&lt;BR /&gt;Hope this helps,&lt;BR /&gt;&lt;BR /&gt;Justo.</description>
      <pubDate>Mon, 10 Jun 2002 13:04:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/read-complete-lines-in-a-for-loop/m-p/2741115#M946827</guid>
      <dc:creator>Justo Exposito</dc:creator>
      <dc:date>2002-06-10T13:04:11Z</dc:date>
    </item>
    <item>
      <title>Re: read complete lines in a for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/read-complete-lines-in-a-for-loop/m-p/2741116#M946828</link>
      <description>With the "while" loop you have more control. For example reading /etc/passwd using ":" as field separator.&lt;BR /&gt;&lt;BR /&gt;IFS=:&lt;BR /&gt;exec 0while read -r Name Pass Uid Gid Comm Home Shell&lt;BR /&gt;do&lt;BR /&gt;print "$Name $Uid $Gid"&lt;BR /&gt;done</description>
      <pubDate>Mon, 10 Jun 2002 13:08:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/read-complete-lines-in-a-for-loop/m-p/2741116#M946828</guid>
      <dc:creator>S.K. Chan</dc:creator>
      <dc:date>2002-06-10T13:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: read complete lines in a for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/read-complete-lines-in-a-for-loop/m-p/2741117#M946829</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;  Please try this..I have tested now&lt;BR /&gt;&lt;BR /&gt;for i in "`cat file`"&lt;BR /&gt;do&lt;BR /&gt;echo "$i"&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Best of luck&lt;BR /&gt;Shahul</description>
      <pubDate>Mon, 10 Jun 2002 13:33:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/read-complete-lines-in-a-for-loop/m-p/2741117#M946829</guid>
      <dc:creator>Shahul</dc:creator>
      <dc:date>2002-06-10T13:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: read complete lines in a for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/read-complete-lines-in-a-for-loop/m-p/2741118#M946830</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Here's another method (takes care of spaces and tabs):&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;inc=1&lt;BR /&gt;total=`cat $1 | wc -l`&lt;BR /&gt;&lt;BR /&gt;while [ "$inc" -le "$total" ]&lt;BR /&gt;do&lt;BR /&gt;  tail -$inc $1 | head -1&lt;BR /&gt;  inc=`expr $inc + 1`&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards.&lt;BR /&gt;&lt;BR /&gt;Steven Sim Kok Leong</description>
      <pubDate>Mon, 10 Jun 2002 14:39:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/read-complete-lines-in-a-for-loop/m-p/2741118#M946830</guid>
      <dc:creator>Steven Sim Kok Leong</dc:creator>
      <dc:date>2002-06-10T14:39:43Z</dc:date>
    </item>
    <item>
      <title>Re: read complete lines in a for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/read-complete-lines-in-a-for-loop/m-p/2741119#M946831</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Sorry, made a typo (swapped the head and tail). Should be:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh &lt;BR /&gt;&lt;BR /&gt;inc=1 &lt;BR /&gt;total=`cat $1 | wc -l` &lt;BR /&gt;&lt;BR /&gt;while [ "$inc" -le "$total" ] &lt;BR /&gt;do &lt;BR /&gt;head -$inc $1 | tail -1 &lt;BR /&gt;inc=`expr $inc + 1` &lt;BR /&gt;done &lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards.&lt;BR /&gt;&lt;BR /&gt;Steven Sim Kok Leong</description>
      <pubDate>Mon, 10 Jun 2002 14:49:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/read-complete-lines-in-a-for-loop/m-p/2741119#M946831</guid>
      <dc:creator>Steven Sim Kok Leong</dc:creator>
      <dc:date>2002-06-10T14:49:19Z</dc:date>
    </item>
    <item>
      <title>Re: read complete lines in a for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/read-complete-lines-in-a-for-loop/m-p/2741120#M946832</link>
      <description>Here is yet another (and the really classic) method - reading using a file descriptor:&lt;BR /&gt;&lt;BR /&gt;INFILE="myfilename"&lt;BR /&gt;&lt;BR /&gt;exec 9&amp;lt;${INFILE}&lt;BR /&gt;X=$(line &amp;lt;&amp;amp;9)&lt;BR /&gt;STAT=$?&lt;BR /&gt;while [ ${STAT} -eq 0 ]&lt;BR /&gt;  do&lt;BR /&gt;    echo "${X}"&lt;BR /&gt;    X=$(line &amp;lt;&amp;amp;9)&lt;BR /&gt;    STAT=$?&lt;BR /&gt;  done&lt;BR /&gt;&lt;BR /&gt;Reading using a file descriptor reads the lines sequentially. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 10 Jun 2002 14:54:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/read-complete-lines-in-a-for-loop/m-p/2741120#M946832</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-06-10T14:54:07Z</dc:date>
    </item>
    <item>
      <title>Re: read complete lines in a for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/read-complete-lines-in-a-for-loop/m-p/2741121#M946833</link>
      <description>Read file by line and print;&lt;BR /&gt;&lt;BR /&gt;# perl -pe 1 file&lt;BR /&gt;&lt;BR /&gt;Read file by line and insert line number at front&lt;BR /&gt;&lt;BR /&gt;# perl -pe 's/^/$. /' file&lt;BR /&gt;&lt;BR /&gt;Read file by line and make it useful (if the content is possitive)&lt;BR /&gt;&lt;BR /&gt;# perl -pe 's/ms-?dos/hp-ux/ig' file</description>
      <pubDate>Mon, 10 Jun 2002 15:22:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/read-complete-lines-in-a-for-loop/m-p/2741121#M946833</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-06-10T15:22:20Z</dc:date>
    </item>
  </channel>
</rss>

