<?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: expr command help in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/expr-command-help/m-p/5103027#M90972</link>
    <description>hi Piyush,&lt;BR /&gt;&lt;BR /&gt;please clarify further. Maybe you can post an extract of the script in question.&lt;BR /&gt;&lt;BR /&gt;thanks&lt;BR /&gt;&lt;BR /&gt;kind regards&lt;BR /&gt;yogeeraj</description>
    <pubDate>Sat, 12 Apr 2008 05:31:36 GMT</pubDate>
    <dc:creator>Yogeeraj_1</dc:creator>
    <dc:date>2008-04-12T05:31:36Z</dc:date>
    <item>
      <title>expr command help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/expr-command-help/m-p/5103024#M90969</link>
      <description>Gurus,&lt;BR /&gt;     I am very new in shell scripting, i am going to create a script which is calculating the average of io utilization. in that script i want to get the average of floating values like.&lt;BR /&gt;5.62&lt;BR /&gt;2.75&lt;BR /&gt;3.41&lt;BR /&gt;1.08&lt;BR /&gt;2.41&lt;BR /&gt;2.69&lt;BR /&gt;----&lt;BR /&gt;&lt;BR /&gt;that means total of all valuses / no. of values. i had used SUM=`expr $SUM + $VALUE`, it shows the following error.&lt;BR /&gt;&lt;BR /&gt;expr: Syntax error&lt;BR /&gt;expr: An integer value was expected.&lt;BR /&gt;&lt;BR /&gt;what should I do to get the average of floationg value.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Piyush Mathiya&lt;BR /&gt;</description>
      <pubDate>Sat, 12 Apr 2008 03:42:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/expr-command-help/m-p/5103024#M90969</guid>
      <dc:creator>piyush mathiya</dc:creator>
      <dc:date>2008-04-12T03:42:00Z</dc:date>
    </item>
    <item>
      <title>Re: expr command help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/expr-command-help/m-p/5103025#M90970</link>
      <description>hi Piyush Mathiya,&lt;BR /&gt;&lt;BR /&gt;A much easier method is using awk:&lt;BR /&gt;&lt;BR /&gt;$ cat sum.awk&lt;BR /&gt;#sum.awk&lt;BR /&gt;{ sum+=$COL}&lt;BR /&gt;END { print sum }&lt;BR /&gt;&lt;BR /&gt;$ cat values.txt&lt;BR /&gt;5.62&lt;BR /&gt;2.75&lt;BR /&gt;3.41&lt;BR /&gt;1.08&lt;BR /&gt;2.41&lt;BR /&gt;2.69&lt;BR /&gt;&lt;BR /&gt;$ awk -f sum.awk COL=1 &amp;lt; values.txt&lt;BR /&gt;17.96&lt;BR /&gt;$&lt;BR /&gt;&lt;BR /&gt;hope this helps!&lt;BR /&gt;kind regards&lt;BR /&gt;yogeeraj</description>
      <pubDate>Sat, 12 Apr 2008 04:31:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/expr-command-help/m-p/5103025#M90970</guid>
      <dc:creator>Yogeeraj_1</dc:creator>
      <dc:date>2008-04-12T04:31:24Z</dc:date>
    </item>
    <item>
      <title>Re: expr command help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/expr-command-help/m-p/5103026#M90971</link>
      <description>Thanks Yogeeraj,&lt;BR /&gt;      I got your concept but i am not geeting how can i write this statment in a script as i had cut that filed from another file. it is do .. while loop and the floating value is stored in "T" variable. &lt;BR /&gt;&lt;BR /&gt;Thanks &lt;BR /&gt;Piyush Mathiya</description>
      <pubDate>Sat, 12 Apr 2008 05:22:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/expr-command-help/m-p/5103026#M90971</guid>
      <dc:creator>piyush mathiya</dc:creator>
      <dc:date>2008-04-12T05:22:55Z</dc:date>
    </item>
    <item>
      <title>Re: expr command help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/expr-command-help/m-p/5103027#M90972</link>
      <description>hi Piyush,&lt;BR /&gt;&lt;BR /&gt;please clarify further. Maybe you can post an extract of the script in question.&lt;BR /&gt;&lt;BR /&gt;thanks&lt;BR /&gt;&lt;BR /&gt;kind regards&lt;BR /&gt;yogeeraj</description>
      <pubDate>Sat, 12 Apr 2008 05:31:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/expr-command-help/m-p/5103027#M90972</guid>
      <dc:creator>Yogeeraj_1</dc:creator>
      <dc:date>2008-04-12T05:31:36Z</dc:date>
    </item>
    <item>
      <title>Re: expr command help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/expr-command-help/m-p/5103028#M90973</link>
      <description>Yogeeraj,&lt;BR /&gt;      What I am doing is.. I have four fields in a file called p1.txt, i have cut 3rd field from the file and i want to calculate the average of that column in a variable "sum".&lt;BR /&gt;sum=0&lt;BR /&gt;cat p1.txt | grep -v "%" | while read line1&lt;BR /&gt;do&lt;BR /&gt;T=`echo $line1 | tr -s " " | cut -f 3 -d " "`&lt;BR /&gt;sum=`expr $sum + $T`&lt;BR /&gt;echo $sum&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;where the "T" is floating value.</description>
      <pubDate>Sat, 12 Apr 2008 05:58:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/expr-command-help/m-p/5103028#M90973</guid>
      <dc:creator>piyush mathiya</dc:creator>
      <dc:date>2008-04-12T05:58:46Z</dc:date>
    </item>
    <item>
      <title>Re: expr command help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/expr-command-help/m-p/5103029#M90974</link>
      <description>&lt;!--!*#--&gt;&amp;gt;i had cut that field from another file. it is do .. while loop and the floating value is stored in "T" variable.&lt;BR /&gt;&lt;BR /&gt;You need to change it to have awk directly read your file and extract that field and average it.  Or take your while loop and create a new file or pipe that you pass to awk (which is probably simpler):&lt;BR /&gt;&lt;BR /&gt;while read stuff; do&lt;BR /&gt;   # some cut stuff&lt;BR /&gt;   echo $T&lt;BR /&gt;done &amp;lt; first-file | awk -v COL=1 '&lt;BR /&gt;{ sum+=$COL }&lt;BR /&gt;END { print sum / NR } '</description>
      <pubDate>Sat, 12 Apr 2008 05:59:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/expr-command-help/m-p/5103029#M90974</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-04-12T05:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: expr command help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/expr-command-help/m-p/5103030#M90975</link>
      <description>&amp;gt; I have four fields in a file called p1.txt, i have cut 3rd field from the file and i want to calculate the average of that column in a variable "sum".&lt;BR /&gt;&lt;BR /&gt;Do it all in awk.&lt;BR /&gt;awk -v COL=3 '&lt;BR /&gt;BEGIN { getline } # skip first line&lt;BR /&gt;{ sum+=$COL }&lt;BR /&gt;END { print sum / NR } ' p1.txt</description>
      <pubDate>Sat, 12 Apr 2008 06:02:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/expr-command-help/m-p/5103030#M90975</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-04-12T06:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: expr command help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/expr-command-help/m-p/5103031#M90976</link>
      <description>hi again,&lt;BR /&gt;&lt;BR /&gt;I think Dennis "Do it all in awk." would be simpler to implement in your case.&lt;BR /&gt;&lt;BR /&gt;Thank you Dennis for the detailed input.&lt;BR /&gt;&lt;BR /&gt;Good luck!&lt;BR /&gt;kind regards&lt;BR /&gt;yogeeraj</description>
      <pubDate>Sat, 12 Apr 2008 06:11:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/expr-command-help/m-p/5103031#M90976</guid>
      <dc:creator>Yogeeraj_1</dc:creator>
      <dc:date>2008-04-12T06:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: expr command help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/expr-command-help/m-p/5103032#M90977</link>
      <description>Denis &amp;amp; Yogeeraj. &lt;BR /&gt;       Thanks for your prompt and realy very helpful answers. Still I want a help. anyone have a good document (Examples) of awk &amp;amp; sed commands. so i can read and learn about this two commands.&lt;BR /&gt;       Problem is resolved. again thanks.!&lt;BR /&gt;Regards,&lt;BR /&gt;Piyush Mathiya&lt;BR /&gt;</description>
      <pubDate>Sat, 12 Apr 2008 06:20:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/expr-command-help/m-p/5103032#M90977</guid>
      <dc:creator>piyush mathiya</dc:creator>
      <dc:date>2008-04-12T06:20:02Z</dc:date>
    </item>
    <item>
      <title>Re: expr command help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/expr-command-help/m-p/5103033#M90978</link>
      <description>hi Piyush,&lt;BR /&gt;&lt;BR /&gt;Start with "man awk" and "man sed"&lt;BR /&gt;&lt;BR /&gt;Also have a look at the following URLs:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.grymoire.com/Unix/Sed.html" target="_blank"&gt;http://www.grymoire.com/Unix/Sed.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.grymoire.com/Unix/Awk.html" target="_blank"&gt;http://www.grymoire.com/Unix/Awk.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;hope this helps!&lt;BR /&gt;&lt;BR /&gt;kind regards&lt;BR /&gt;yogeeraj</description>
      <pubDate>Sat, 12 Apr 2008 06:30:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/expr-command-help/m-p/5103033#M90978</guid>
      <dc:creator>Yogeeraj_1</dc:creator>
      <dc:date>2008-04-12T06:30:34Z</dc:date>
    </item>
    <item>
      <title>Re: expr command help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/expr-command-help/m-p/5103034#M90979</link>
      <description>&amp;gt;anyone have a good document (Examples) of awk &amp;amp; sed commands. so i can read and learn about this two commands.&lt;BR /&gt;&lt;BR /&gt;I typically just use the man page.  But a quick google search finds for awk:&lt;BR /&gt;&lt;A href="http://www.ibm.com/developerworks/library/l-awk1.html" target="_blank"&gt;http://www.ibm.com/developerworks/library/l-awk1.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.gnulamp.com/awkexamples.html" target="_blank"&gt;http://www.gnulamp.com/awkexamples.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.linuxfocus.org/English/September1999/article103.html" target="_blank"&gt;http://www.linuxfocus.org/English/September1999/article103.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.softpanorama.org/Tools/awk.shtml" target="_blank"&gt;http://www.softpanorama.org/Tools/awk.shtml&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.vectorsite.net/tsawk_3.html" target="_blank"&gt;http://www.vectorsite.net/tsawk_3.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://sparky.rice.edu/~hartigan/awk.html" target="_blank"&gt;http://sparky.rice.edu/~hartigan/awk.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.cs.hmc.edu/qref/awk.html" target="_blank"&gt;http://www.cs.hmc.edu/qref/awk.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.gentoo.org/doc/en/articles/l-awk2.xml" target="_blank"&gt;http://www.gentoo.org/doc/en/articles/l-awk2.xml&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.freeos.com/guides/lsst/ch07sec09.html" target="_blank"&gt;http://www.freeos.com/guides/lsst/ch07sec09.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;And the same for sed:&lt;BR /&gt;&lt;A href="http://student.northpark.edu/pemente/sed/sed1line.txt" target="_blank"&gt;http://student.northpark.edu/pemente/sed/sed1line.txt&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.ibm.com/developerworks/linux/library/l-sed1.html" target="_blank"&gt;http://www.ibm.com/developerworks/linux/library/l-sed1.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.ibm.com/developerworks/linux/library/l-sed2.html" target="_blank"&gt;http://www.ibm.com/developerworks/linux/library/l-sed2.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.grymoire.com/Unix/Sed.html" target="_blank"&gt;http://www.grymoire.com/Unix/Sed.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.gnulamp.com/sed.html" target="_blank"&gt;http://www.gnulamp.com/sed.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.cs.utk.edu/~vose/c-stuff/sed_tutorial.html" target="_blank"&gt;http://www.cs.utk.edu/~vose/c-stuff/sed_tutorial.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://people.debian.org/~caiqian/programming/sed/l-sed1.html" target="_blank"&gt;http://people.debian.org/~caiqian/programming/sed/l-sed1.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.gentoo.org/doc/en/articles/l-sed1.xml" target="_blank"&gt;http://www.gentoo.org/doc/en/articles/l-sed1.xml&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.freeos.com/guides/lsst/ch07sec14.html" target="_blank"&gt;http://www.freeos.com/guides/lsst/ch07sec14.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.emunix.emich.edu/~khailany/files/sed-examples.htm" target="_blank"&gt;http://www.emunix.emich.edu/~khailany/files/sed-examples.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;There is probably some duplication in the links.</description>
      <pubDate>Sat, 12 Apr 2008 06:32:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/expr-command-help/m-p/5103034#M90979</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-04-12T06:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: expr command help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/expr-command-help/m-p/5103035#M90980</link>
      <description>Thanks,&lt;BR /&gt;</description>
      <pubDate>Sat, 12 Apr 2008 07:39:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/expr-command-help/m-p/5103035#M90980</guid>
      <dc:creator>piyush mathiya</dc:creator>
      <dc:date>2008-04-12T07:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: expr command help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/expr-command-help/m-p/5103036#M90981</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Most shells only support integer arithmetic as you have found.  While I would probably also use 'awk' (or Perl), the Korn93 shell supports floating point arithmetic.&lt;BR /&gt;&lt;BR /&gt;In HP-UX the Korn shell in '/usr/bin/ksh' is the Korn88 variant and this lacks the support you seek.&lt;BR /&gt;&lt;BR /&gt;However, the Korn93 shell lives in '/usr/dt/bin/dtksh'.  For example:&lt;BR /&gt;&lt;BR /&gt;# cat ./float&lt;BR /&gt;#/usr/dt/bin/dtksh&lt;BR /&gt;typeset -F  R1&lt;BR /&gt;typeset -F3 R2&lt;BR /&gt;typeset -E  R3&lt;BR /&gt;let R1=1/8&lt;BR /&gt;echo $R1&lt;BR /&gt;let R2=1/8&lt;BR /&gt;echo $R2&lt;BR /&gt;let R3=1/8&lt;BR /&gt;echo $R3&lt;BR /&gt;&lt;BR /&gt;# ./float      &lt;BR /&gt;.1250000000&lt;BR /&gt;.125&lt;BR /&gt;0.125&lt;BR /&gt;&lt;BR /&gt;A google search for 'Korn shell' will yield more information.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Sat, 12 Apr 2008 12:54:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/expr-command-help/m-p/5103036#M90981</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-04-12T12:54:02Z</dc:date>
    </item>
  </channel>
</rss>

