<?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: Korn shell script problem in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-problem/m-p/3429713#M707370</link>
    <description>Thanks Jean,&lt;BR /&gt;&lt;BR /&gt;But is the awk command I issued correct?&lt;BR /&gt;&lt;BR /&gt;thanks!</description>
    <pubDate>Wed, 24 Nov 2004 09:48:51 GMT</pubDate>
    <dc:creator>Henry Chua</dc:creator>
    <dc:date>2004-11-24T09:48:51Z</dc:date>
    <item>
      <title>Korn shell script problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-problem/m-p/3429711#M707368</link>
      <description>I can't seems to make this program work. It is suppose to read line by line of file TAR until EOF. something seems to be run with the awk command, I dun seems to know whether to put the ` ' or " . anyone can help?&lt;BR /&gt;&lt;BR /&gt;y=1&lt;BR /&gt;x=1&lt;BR /&gt;while [ y -ne 0 ]&lt;BR /&gt;do&lt;BR /&gt;awk "NR==$x" $TAR &amp;gt; $BUF&lt;BR /&gt;let "x=x+1"&lt;BR /&gt;y=`wc -c $BUF`&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Wed, 24 Nov 2004 09:39:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-problem/m-p/3429711#M707368</guid>
      <dc:creator>Henry Chua</dc:creator>
      <dc:date>2004-11-24T09:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: Korn shell script problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-problem/m-p/3429712#M707369</link>
      <description>would that be &lt;BR /&gt;while [ $y -ne 0 ]&lt;BR /&gt;instead of&lt;BR /&gt;while [ y -ne 0 ]&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Jean-Luc</description>
      <pubDate>Wed, 24 Nov 2004 09:43:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-problem/m-p/3429712#M707369</guid>
      <dc:creator>Jean-Luc Oudart</dc:creator>
      <dc:date>2004-11-24T09:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: Korn shell script problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-problem/m-p/3429713#M707370</link>
      <description>Thanks Jean,&lt;BR /&gt;&lt;BR /&gt;But is the awk command I issued correct?&lt;BR /&gt;&lt;BR /&gt;thanks!</description>
      <pubDate>Wed, 24 Nov 2004 09:48:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-problem/m-p/3429713#M707370</guid>
      <dc:creator>Henry Chua</dc:creator>
      <dc:date>2004-11-24T09:48:51Z</dc:date>
    </item>
    <item>
      <title>Re: Korn shell script problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-problem/m-p/3429714#M707371</link>
      <description>Hi Henry,&lt;BR /&gt;&lt;BR /&gt;I don't know what you are trying to do. Why do you want to use a script to read it line by line? Can you do something like&lt;BR /&gt;&lt;BR /&gt;while read line&lt;BR /&gt;do&lt;BR /&gt;echo $line&lt;BR /&gt;&lt;DO_SOMETHING_WITH_&gt;&lt;BR /&gt;done &amp;lt; $TAR&lt;BR /&gt;&lt;BR /&gt;to read line by line?.&lt;BR /&gt;&lt;BR /&gt;If you insist on using the script, then there are couple of issues.&lt;BR /&gt;&lt;BR /&gt;1. while [ y -ne 0 ] should be while [ $y -ne 0 ]. Use [[ and ]] instead.&lt;BR /&gt;2. awk "NR==$x" won't work. You can't assing a shell variable inside awk. Do&lt;BR /&gt;awk -v x=$x 'NR==x' $TAR &amp;gt; $BUF&lt;BR /&gt;No $ for variables inside awk. &lt;BR /&gt;3. Try (( x = $x + 1 )) instead of let.&lt;BR /&gt;&lt;BR /&gt;-Sri&lt;/DO_SOMETHING_WITH_&gt;</description>
      <pubDate>Wed, 24 Nov 2004 09:49:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-problem/m-p/3429714#M707371</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2004-11-24T09:49:53Z</dc:date>
    </item>
    <item>
      <title>Re: Korn shell script problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-problem/m-p/3429715#M707372</link>
      <description>Hi Sri &lt;BR /&gt;&lt;BR /&gt;as advised I used&lt;BR /&gt;"awk -v x=$x 'NR==x' $TAR &amp;gt; $BUF"&lt;BR /&gt;and it produces &lt;BR /&gt;&lt;BR /&gt;awk: syntax error near line 1&lt;BR /&gt;awk: bailing out near line 1&lt;BR /&gt;&lt;BR /&gt;what could be wrong?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;thanks!&lt;BR /&gt;</description>
      <pubDate>Wed, 24 Nov 2004 09:59:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-problem/m-p/3429715#M707372</guid>
      <dc:creator>Henry Chua</dc:creator>
      <dc:date>2004-11-24T09:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: Korn shell script problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-problem/m-p/3429716#M707373</link>
      <description>It works for me. Try with sh -x &amp;lt;script&amp;gt; and see if you get more information.&lt;BR /&gt;&lt;BR /&gt;$TAR=testfile&lt;BR /&gt;$x=2&lt;BR /&gt;$awk -v x=$x 'NR==x' $TAR&lt;BR /&gt;testline 2&lt;BR /&gt;&lt;BR /&gt;-Sri&lt;BR /&gt;</description>
      <pubDate>Wed, 24 Nov 2004 10:16:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-problem/m-p/3429716#M707373</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2004-11-24T10:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: Korn shell script problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-problem/m-p/3429717#M707374</link>
      <description>Henry,&lt;BR /&gt;&lt;BR /&gt;When I first started working with unix, one of my colleagues said "A shell script doesn't deserve the name shell script unless it contains at least one awk".&lt;BR /&gt;&lt;BR /&gt;I don't agree with him! Sri's "while read line" suggestion is just as effective as awk and easier to script.&lt;BR /&gt;&lt;BR /&gt;Mark Syder (like the drink but spelt different)</description>
      <pubDate>Wed, 24 Nov 2004 10:18:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-problem/m-p/3429717#M707374</guid>
      <dc:creator>MarkSyder</dc:creator>
      <dc:date>2004-11-24T10:18:54Z</dc:date>
    </item>
    <item>
      <title>Re: Korn shell script problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-problem/m-p/3429718#M707375</link>
      <description>You can indeed use shell variables in&lt;BR /&gt;an awk program, but only because the shell&lt;BR /&gt;substitutes inside of double quotes:&lt;BR /&gt;&lt;BR /&gt;x=2&lt;BR /&gt;awk "NR == $x" some_file&lt;BR /&gt;&lt;BR /&gt;If you use single quotes the shell won't&lt;BR /&gt;substitute for $x.&lt;BR /&gt;&lt;BR /&gt;However, I don't understand why you are&lt;BR /&gt;doing this in such a roundabout manner.&lt;BR /&gt;Replacing your entire program with&lt;BR /&gt;"cat $TAR" will also read from TAR until&lt;BR /&gt;EOF.  What are you trying to accomplish?&lt;BR /&gt;</description>
      <pubDate>Wed, 24 Nov 2004 15:53:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-problem/m-p/3429718#M707375</guid>
      <dc:creator>Gregory Fruth</dc:creator>
      <dc:date>2004-11-24T15:53:17Z</dc:date>
    </item>
    <item>
      <title>Re: Korn shell script problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-problem/m-p/3429719#M707376</link>
      <description>hi Sri,&lt;BR /&gt;&lt;BR /&gt;DOes that mean I can read line 1 of the file this way:&lt;BR /&gt;"&lt;BR /&gt;TAR = filename&lt;BR /&gt;x=1&lt;BR /&gt;while read x&lt;BR /&gt;do&lt;BR /&gt;echo $x&lt;BR /&gt;&lt;DO_SOMETHING_WITH_&gt;&lt;BR /&gt;done &amp;lt; $TAR&lt;BR /&gt;"&lt;BR /&gt;Thanks!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/DO_SOMETHING_WITH_&gt;</description>
      <pubDate>Wed, 24 Nov 2004 18:37:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-problem/m-p/3429719#M707376</guid>
      <dc:creator>Henry Chua</dc:creator>
      <dc:date>2004-11-24T18:37:41Z</dc:date>
    </item>
    <item>
      <title>Re: Korn shell script problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-problem/m-p/3429720#M707377</link>
      <description>I got it! thank!!!</description>
      <pubDate>Wed, 24 Nov 2004 19:51:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-problem/m-p/3429720#M707377</guid>
      <dc:creator>Henry Chua</dc:creator>
      <dc:date>2004-11-24T19:51:34Z</dc:date>
    </item>
  </channel>
</rss>

