<?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: How to compare 2 numbers from a string in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/how-to-compare-2-numbers-from-a-string/m-p/4927508#M104889</link>
    <description>Hi Carles:&lt;BR /&gt;&lt;BR /&gt;You can force 'awk' to intergize by adding zero.  Try this:&lt;BR /&gt;&lt;BR /&gt;bdf -l|tail +2|awk '{n=substr($5,1);n=n+0;if (n &amp;gt; 85 &amp;amp;&amp;amp; $6 == "/FAR/oracle/arch" {print}}'&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Tue, 20 Sep 2005 12:25:41 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2005-09-20T12:25:41Z</dc:date>
    <item>
      <title>How to compare 2 numbers from a string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-compare-2-numbers-from-a-string/m-p/4927507#M104888</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;I need to check filesystem used and free space, so I want to get percentage and compare it with a value.&lt;BR /&gt;&lt;BR /&gt;Script I'm using doesn't work fine in some cases due data I get from system is a string (ie, in case of percentage is 9, for my script it's greater than 85):&lt;BR /&gt;&lt;BR /&gt;bdf -l|tail +2|awk 'substr($5,1,length($5)-1) &amp;gt; 85 &amp;amp;&amp;amp;  $6 == "/FAR/oracle/arch" {print}'&lt;BR /&gt;&lt;BR /&gt;Is there any way to change format to an integer or to change "&amp;gt;" for any other command?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance,&lt;BR /&gt;&lt;BR /&gt;Carles&lt;BR /&gt;</description>
      <pubDate>Tue, 20 Sep 2005 12:15:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-compare-2-numbers-from-a-string/m-p/4927507#M104888</guid>
      <dc:creator>Carles Viaplana</dc:creator>
      <dc:date>2005-09-20T12:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare 2 numbers from a string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-compare-2-numbers-from-a-string/m-p/4927508#M104889</link>
      <description>Hi Carles:&lt;BR /&gt;&lt;BR /&gt;You can force 'awk' to intergize by adding zero.  Try this:&lt;BR /&gt;&lt;BR /&gt;bdf -l|tail +2|awk '{n=substr($5,1);n=n+0;if (n &amp;gt; 85 &amp;amp;&amp;amp; $6 == "/FAR/oracle/arch" {print}}'&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 20 Sep 2005 12:25:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-compare-2-numbers-from-a-string/m-p/4927508#M104889</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2005-09-20T12:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare 2 numbers from a string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-compare-2-numbers-from-a-string/m-p/4927509#M104890</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;Oops, I dropped the chop of the "%":&lt;BR /&gt;&lt;BR /&gt;# bdf -l|tail +2|awk '{n=substr($5,1,(length($5)-1));n=n+0;if (n &amp;gt; 85 &amp;amp;&amp;amp; $6 == "/FAR/oracle/arch" {print}}'&lt;BR /&gt;&lt;BR /&gt;You could also eliminate the extra process (the 'tail':&lt;BR /&gt;&lt;BR /&gt;# smhmso # bdf -l|awk '{NR&amp;gt;2;n=substr($5,1,($length($5)-1));n=n+0;if (n &amp;gt; 85 &amp;amp;&amp;amp; $6 == "/FAR/oracle/arch" {print}}'&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 20 Sep 2005 12:41:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-compare-2-numbers-from-a-string/m-p/4927509#M104890</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2005-09-20T12:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare 2 numbers from a string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-compare-2-numbers-from-a-string/m-p/4927510#M104891</link>
      <description>&lt;BR /&gt;I would let awk do more work:&lt;BR /&gt;&lt;BR /&gt;bdf -l| awk '/arch$/{sub(/%/,"",$5); if ((0+$5)&amp;gt;85){print}}'&lt;BR /&gt;&lt;BR /&gt;Here tail is replaced by awk just lookinf for a line ending in 'arch'.&lt;BR /&gt;You can extent that to \/FAR\/oracle\/arch$ if need be.&lt;BR /&gt;It then replaces the % in $5 with nothing, converts to numeric and compares.&lt;BR /&gt;&lt;BR /&gt;fwiw,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Tue, 20 Sep 2005 13:02:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-compare-2-numbers-from-a-string/m-p/4927510#M104891</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-09-20T13:02:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare 2 numbers from a string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-compare-2-numbers-from-a-string/m-p/4927511#M104892</link>
      <description>Is the output of bdf -l getting wrapped onto another line (happens when the name of the devices is long)???&lt;BR /&gt;&lt;BR /&gt;If that's the case then your script will not be able to parse, compare and print the filesystems that are exceeding your "&amp;gt; 85" criteria. You need to modify your script as:&lt;BR /&gt;&lt;BR /&gt;# bdf -l | awk 'NR!=1 &amp;amp;&amp;amp; NF!=1 &amp;amp;&amp;amp; substr($(NF-1),1,length($(NF-1))-1) &amp;gt; 85 &amp;amp;&amp;amp; $6 == "/FAR/oracle/arch" {print}'&lt;BR /&gt;</description>
      <pubDate>Tue, 20 Sep 2005 15:21:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-compare-2-numbers-from-a-string/m-p/4927511#M104892</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2005-09-20T15:21:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare 2 numbers from a string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-compare-2-numbers-from-a-string/m-p/4927512#M104893</link>
      <description>Hello...small change to the previous posting; change the $6 with $NF i.e.&lt;BR /&gt;&lt;BR /&gt;# bdf -l | awk 'NR!=1 &amp;amp;&amp;amp; NF!=1 &amp;amp;&amp;amp; substr($(NF-1),1,length($(NF-1))-1) &amp;gt; 85 &amp;amp;&amp;amp; $NF == "/FAR/oracle/arch" {print}'&lt;BR /&gt;&lt;BR /&gt;regards!</description>
      <pubDate>Tue, 20 Sep 2005 15:24:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-compare-2-numbers-from-a-string/m-p/4927512#M104893</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2005-09-20T15:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare 2 numbers from a string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-compare-2-numbers-from-a-string/m-p/4927513#M104894</link>
      <description>As mentioned, bdf is unstable when it comes to the lines of data. If you use bdf directly, your script will fail with long device filenames or NFS mountpoints. It is a very common task so I've attached a useful diskspace monitoring script with configurable % per mountpoint *and* a notification only once per limit, with another notice when the usage increases a specified amount over the limit.</description>
      <pubDate>Tue, 20 Sep 2005 15:48:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-compare-2-numbers-from-a-string/m-p/4927513#M104894</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2005-09-20T15:48:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare 2 numbers from a string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-compare-2-numbers-from-a-string/m-p/4927514#M104895</link>
      <description>Here's a perl script I wrote to force bdf into 1 line per filesystem.  The problem referenced in Bills post.</description>
      <pubDate>Tue, 20 Sep 2005 18:38:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-compare-2-numbers-from-a-string/m-p/4927514#M104895</guid>
      <dc:creator>Alan Meyer_4</dc:creator>
      <dc:date>2005-09-20T18:38:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare 2 numbers from a string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-compare-2-numbers-from-a-string/m-p/4927515#M104896</link>
      <description>I applied solution provided by James and it works fine.&lt;BR /&gt;&lt;BR /&gt;Thanks to all!</description>
      <pubDate>Wed, 21 Sep 2005 01:59:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-compare-2-numbers-from-a-string/m-p/4927515#M104896</guid>
      <dc:creator>Carles Viaplana</dc:creator>
      <dc:date>2005-09-21T01:59:04Z</dc:date>
    </item>
  </channel>
</rss>

