<?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 while read loop help in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/while-read-loop-help/m-p/4577112#M679254</link>
    <description>I have written a script using a loop but when I execute it using while read, it only read the first line and quits the loop after processing the first line. If I change it from (while read) to (for i in) it reads all the lines and finishes the loop?&lt;BR /&gt;&lt;BR /&gt;any advice will be appreciated&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Avinash&lt;BR /&gt;</description>
    <pubDate>Wed, 03 Feb 2010 10:37:07 GMT</pubDate>
    <dc:creator>Avinash Agarkar</dc:creator>
    <dc:date>2010-02-03T10:37:07Z</dc:date>
    <item>
      <title>while read loop help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-read-loop-help/m-p/4577112#M679254</link>
      <description>I have written a script using a loop but when I execute it using while read, it only read the first line and quits the loop after processing the first line. If I change it from (while read) to (for i in) it reads all the lines and finishes the loop?&lt;BR /&gt;&lt;BR /&gt;any advice will be appreciated&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Avinash&lt;BR /&gt;</description>
      <pubDate>Wed, 03 Feb 2010 10:37:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-read-loop-help/m-p/4577112#M679254</guid>
      <dc:creator>Avinash Agarkar</dc:creator>
      <dc:date>2010-02-03T10:37:07Z</dc:date>
    </item>
    <item>
      <title>Re: while read loop help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-read-loop-help/m-p/4577113#M679255</link>
      <description>hi,&lt;BR /&gt;&lt;BR /&gt;the bets way is to send the loop that you are using.&lt;BR /&gt;&lt;BR /&gt;mikap</description>
      <pubDate>Wed, 03 Feb 2010 12:19:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-read-loop-help/m-p/4577113#M679255</guid>
      <dc:creator>Michal Kapalka (mikap)</dc:creator>
      <dc:date>2010-02-03T12:19:40Z</dc:date>
    </item>
    <item>
      <title>Re: while read loop help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-read-loop-help/m-p/4577114#M679256</link>
      <description>This is the wrong forum for scripting.&lt;BR /&gt;What OS and shell are you using?</description>
      <pubDate>Thu, 04 Feb 2010 11:49:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-read-loop-help/m-p/4577114#M679256</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2010-02-04T11:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: while read loop help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-read-loop-help/m-p/4577115#M679257</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;I would urge you to *post* your code.  I suspect that you need two file descriptors --- one for the 'read' loop and another for the process you want to execute.  If an 'ssh' or 'remsh' is called within the loop you will likely need to add the '-n' option to it.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 04 Feb 2010 14:38:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-read-loop-help/m-p/4577115#M679257</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-02-04T14:38:34Z</dc:date>
    </item>
    <item>
      <title>Re: while read loop help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-read-loop-help/m-p/4577116#M679258</link>
      <description>&lt;!--!*#--&gt;Most likely you haven't noticed that the input/output redirection works a bit oddly in loop structures.&lt;BR /&gt;&lt;BR /&gt;Wrong:&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;# this reads only the first line&lt;BR /&gt;while read foo &amp;lt; inputfile.txt&lt;BR /&gt;do&lt;BR /&gt;    echo "$foo"&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Right:&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;# this processes all lines in the file&lt;BR /&gt;while read foo&lt;BR /&gt;do &lt;BR /&gt;    echo "$foo"&lt;BR /&gt;done &amp;lt; inputfile.txt&lt;BR /&gt;&lt;BR /&gt;The "for i in $(cat inputfile.txt)" style loop is not suitable for files longer than the maximum command line length (8 KiB or so). If the file is longer than that, the script dies with "Command line too long" or equivalent error message. &lt;BR /&gt;&lt;BR /&gt;With smaller files, it might work... but not the same as the "while read" loop: $i will iterate over the content of the input file, but one _word_ at a time, not one _line_ at a time.&lt;BR /&gt;&lt;BR /&gt;MK</description>
      <pubDate>Thu, 04 Feb 2010 14:57:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-read-loop-help/m-p/4577116#M679258</guid>
      <dc:creator>Matti_Kurkela</dc:creator>
      <dc:date>2010-02-04T14:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: while read loop help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-read-loop-help/m-p/4577117#M679259</link>
      <description>HI&lt;BR /&gt;&lt;BR /&gt;cat file | while read a (* or, number of words per line, a b c d e *)&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;echo $a  (* whole line *)&lt;BR /&gt;&lt;BR /&gt;done</description>
      <pubDate>Fri, 05 Feb 2010 00:43:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-read-loop-help/m-p/4577117#M679259</guid>
      <dc:creator>Michael Steele_2</dc:creator>
      <dc:date>2010-02-05T00:43:33Z</dc:date>
    </item>
    <item>
      <title>Re: while read loop help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-read-loop-help/m-p/4577118#M679260</link>
      <description>Hi Avinash,&lt;BR /&gt;Please post the code which would help.&lt;BR /&gt;&lt;BR /&gt;Sagar</description>
      <pubDate>Fri, 05 Feb 2010 04:23:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-read-loop-help/m-p/4577118#M679260</guid>
      <dc:creator>Sagar Sirdesai</dc:creator>
      <dc:date>2010-02-05T04:23:37Z</dc:date>
    </item>
  </channel>
</rss>

