<?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: Awk in Shell in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/awk-in-shell/m-p/5035814#M95801</link>
    <description>&amp;gt;where I have assigned some command to $command.&lt;BR /&gt;&lt;BR /&gt;Since your awk script is in '', $variables aren't expanded and they are treated as awk fields.  &lt;BR /&gt;&lt;BR /&gt;You will have to change the script to:&lt;BR /&gt;&lt;BR /&gt;echo "$value $value2"|awk -v command="$command" '&lt;BR /&gt;{...&lt;BR /&gt;system(command);</description>
    <pubDate>Fri, 23 Mar 2007 00:22:10 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2007-03-23T00:22:10Z</dc:date>
    <item>
      <title>Awk in Shell</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-in-shell/m-p/5035813#M95800</link>
      <description>Hi,&lt;BR /&gt;The following is a part of my shell script.&lt;BR /&gt;----------------------------------------------&lt;BR /&gt;echo "$value $value2"|awk '&lt;BR /&gt;{&lt;BR /&gt;if ($1 &amp;lt;= $2)&lt;BR /&gt;system($command);&lt;BR /&gt;else&lt;BR /&gt;print 0;&lt;BR /&gt;}'&lt;BR /&gt;----------------------------------------------&lt;BR /&gt;where I have assigned some command to $command.&lt;BR /&gt;&lt;BR /&gt;While running the script I am getting the error like&lt;BR /&gt;----------------------------------------------&lt;BR /&gt;Value1 is: 903824&lt;BR /&gt;Value2 is: 2456910.90&lt;BR /&gt;903824 2456910.90&lt;BR /&gt;awk: Field $() is not correct.&lt;BR /&gt; The input line number is 1.&lt;BR /&gt; The source line number is 4.&lt;BR /&gt;----------------------------------------------&lt;BR /&gt;But if i change the if condition to $1&amp;gt;=$2,&lt;BR /&gt;&lt;BR /&gt;I am getting the output like,&lt;BR /&gt;------------------------&lt;BR /&gt;Value1 is: 903837&lt;BR /&gt;Value2 is: 2456972.10&lt;BR /&gt;903837 2456972.10&lt;BR /&gt;0&lt;BR /&gt;--------------------------&lt;BR /&gt;Is there any other way to compare 2 floating values other than the above.&lt;BR /&gt;&lt;BR /&gt;Could you please clarify me in the above and to rectify my errors&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Arun&lt;BR /&gt;</description>
      <pubDate>Thu, 22 Mar 2007 23:57:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-in-shell/m-p/5035813#M95800</guid>
      <dc:creator>Arun Kumar Rajamari</dc:creator>
      <dc:date>2007-03-22T23:57:01Z</dc:date>
    </item>
    <item>
      <title>Re: Awk in Shell</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-in-shell/m-p/5035814#M95801</link>
      <description>&amp;gt;where I have assigned some command to $command.&lt;BR /&gt;&lt;BR /&gt;Since your awk script is in '', $variables aren't expanded and they are treated as awk fields.  &lt;BR /&gt;&lt;BR /&gt;You will have to change the script to:&lt;BR /&gt;&lt;BR /&gt;echo "$value $value2"|awk -v command="$command" '&lt;BR /&gt;{...&lt;BR /&gt;system(command);</description>
      <pubDate>Fri, 23 Mar 2007 00:22:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-in-shell/m-p/5035814#M95801</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-03-23T00:22:10Z</dc:date>
    </item>
    <item>
      <title>Re: Awk in Shell</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-in-shell/m-p/5035815#M95802</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;another possibilities to give awk the content of a shell variable:&lt;BR /&gt;1)&lt;BR /&gt;echo "$value $value2"|awk '&lt;BR /&gt;{&lt;BR /&gt;if ($1 &amp;lt;= $2)&lt;BR /&gt;system("'"$command"'");&lt;BR /&gt;else&lt;BR /&gt;print 0;&lt;BR /&gt;}'&lt;BR /&gt;&lt;BR /&gt;2)&lt;BR /&gt;export command&lt;BR /&gt;echo "$value $value2"|awk '&lt;BR /&gt;{&lt;BR /&gt;if ($1 &amp;lt;= $2)&lt;BR /&gt;system(ENVIRON["command"]);&lt;BR /&gt;else&lt;BR /&gt;print 0;&lt;BR /&gt;}'&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Fri, 23 Mar 2007 03:03:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-in-shell/m-p/5035815#M95802</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2007-03-23T03:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: Awk in Shell</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-in-shell/m-p/5035816#M95803</link>
      <description>Hmmm, the assigned points (5) suggest the problem is not solved, but there is no indication on what is (still) wrong.&lt;BR /&gt;&lt;BR /&gt;I have no HPUX system up right now to test, so I tried on Windoze..&lt;BR /&gt;&lt;BR /&gt;- Are you sure ydeou want those quotes around the values? On Windows they ended up in $1 and $2. To test replace the system call with 'print "1:", $1, "2:", $2'.&lt;BR /&gt;&lt;BR /&gt;- Clean up the if-then-else.&lt;BR /&gt;Use parantheses: &lt;BR /&gt;&lt;BR /&gt;if ($1 &amp;lt;= $2) {&lt;BR /&gt;system($command);&lt;BR /&gt;} else {&lt;BR /&gt;print 0;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;- As replied... the $command substitution will not work. You'll need to feed it through ENVIRON or a -v, or as still more text to that echo:&lt;BR /&gt;&lt;BR /&gt;echo "$v1 $v2 $command" | ....&lt;BR /&gt;...system ("$3 $4 $5...)"...&lt;BR /&gt;&lt;BR /&gt;hth,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Sat, 24 Mar 2007 08:14:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-in-shell/m-p/5035816#M95803</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-03-24T08:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: Awk in Shell</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-in-shell/m-p/5035817#M95804</link>
      <description>Followed the above commands and got it worked &lt;BR /&gt;Thanks,&lt;BR /&gt;Arun</description>
      <pubDate>Tue, 24 Apr 2007 10:15:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-in-shell/m-p/5035817#M95804</guid>
      <dc:creator>Arun Kumar Rajamari</dc:creator>
      <dc:date>2007-04-24T10:15:12Z</dc:date>
    </item>
  </channel>
</rss>

