<?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 check whether a field is numeric in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/how-to-check-whether-a-field-is-numeric/m-p/3944235#M97584</link>
    <description>hey thanks a lot &lt;BR /&gt;but.. &lt;BR /&gt;i want to print the field number and also record number&lt;BR /&gt;if the 4th and 5th field is not numeric&lt;BR /&gt;pls help</description>
    <pubDate>Wed, 14 Feb 2007 04:45:17 GMT</pubDate>
    <dc:creator>Pavitra</dc:creator>
    <dc:date>2007-02-14T04:45:17Z</dc:date>
    <item>
      <title>How to check whether a field is numeric</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-check-whether-a-field-is-numeric/m-p/3944232#M97581</link>
      <description>Hi all,&lt;BR /&gt;i have a file containing comma separated fields,&lt;BR /&gt;i want to check whether the field 4 and field 5 is numeric or not&lt;BR /&gt;(not in perl pls)</description>
      <pubDate>Wed, 14 Feb 2007 04:16:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-check-whether-a-field-is-numeric/m-p/3944232#M97581</guid>
      <dc:creator>Pavitra</dc:creator>
      <dc:date>2007-02-14T04:16:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to check whether a field is numeric</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-check-whether-a-field-is-numeric/m-p/3944233#M97582</link>
      <description>&lt;BR /&gt;awk -F, '($4 ~ /^[0-9]+$/) &amp;amp;&amp;amp; ($5 ~/^[0-9]+$/){print $0}' filename&lt;BR /&gt;&lt;BR /&gt;will print the lines with numeric fields on columns 4 and 5.&lt;BR /&gt;&lt;BR /&gt;hth</description>
      <pubDate>Wed, 14 Feb 2007 04:32:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-check-whether-a-field-is-numeric/m-p/3944233#M97582</guid>
      <dc:creator>Orhan Biyiklioglu</dc:creator>
      <dc:date>2007-02-14T04:32:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to check whether a field is numeric</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-check-whether-a-field-is-numeric/m-p/3944234#M97583</link>
      <description>Pavitra,&lt;BR /&gt;this is NOT the short way of doing it, but it is pretty self-explanatory:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;while read record&lt;BR /&gt;do&lt;BR /&gt;field4=`echo $record | awk -F',' '{print $4}' | tr -d [:digit:]`&lt;BR /&gt;field5=`echo $record | awk -F',' '{print $5}' | tr -d [:digit:]`&lt;BR /&gt;if [ -z "$field4" ]&lt;BR /&gt;then&lt;BR /&gt;echo "Field 4 is numeric"&lt;BR /&gt;fi&lt;BR /&gt;if [ -z  "$field5" ]&lt;BR /&gt;then&lt;BR /&gt;echo "Field 5 is numeric"&lt;BR /&gt;fi&lt;BR /&gt;done &amp;lt; data.lis&lt;BR /&gt;&lt;BR /&gt;Assumtions:&lt;BR /&gt;integers only</description>
      <pubDate>Wed, 14 Feb 2007 04:38:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-check-whether-a-field-is-numeric/m-p/3944234#M97583</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2007-02-14T04:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to check whether a field is numeric</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-check-whether-a-field-is-numeric/m-p/3944235#M97584</link>
      <description>hey thanks a lot &lt;BR /&gt;but.. &lt;BR /&gt;i want to print the field number and also record number&lt;BR /&gt;if the 4th and 5th field is not numeric&lt;BR /&gt;pls help</description>
      <pubDate>Wed, 14 Feb 2007 04:45:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-check-whether-a-field-is-numeric/m-p/3944235#M97584</guid>
      <dc:creator>Pavitra</dc:creator>
      <dc:date>2007-02-14T04:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to check whether a field is numeric</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-check-whether-a-field-is-numeric/m-p/3944236#M97585</link>
      <description>Hi,&lt;BR /&gt;modified for record count etc.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;count=0&lt;BR /&gt;while read record&lt;BR /&gt;do&lt;BR /&gt;count=`expr $count + 1`&lt;BR /&gt;field4=`echo $record | awk -F',' '{print $4}' | tr -d [:digit:]`&lt;BR /&gt;field5=`echo $record | awk -F',' '{print $5}' | tr -d [:digit:]`&lt;BR /&gt;if [ -n "$field4" ] -o [ -n "$field5" ]&lt;BR /&gt;then&lt;BR /&gt;echo "In record $count Field 4 [ $field4 ] or Field 5  [ $field5 ]is not numeric"&lt;BR /&gt;fi&lt;BR /&gt;done &amp;lt;</description>
      <pubDate>Wed, 14 Feb 2007 04:51:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-check-whether-a-field-is-numeric/m-p/3944236#M97585</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2007-02-14T04:51:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to check whether a field is numeric</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-check-whether-a-field-is-numeric/m-p/3944237#M97586</link>
      <description>Yet another one liner:&lt;BR /&gt;&lt;BR /&gt;awk -F, '($4 ~ /^[0-9]+$/) &amp;amp;&amp;amp; ($5 ~/^[0-9]+$/){print FNR," fields 4 and 5 are not numeric!"}' filename&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;hth</description>
      <pubDate>Wed, 14 Feb 2007 05:09:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-check-whether-a-field-is-numeric/m-p/3944237#M97586</guid>
      <dc:creator>Orhan Biyiklioglu</dc:creator>
      <dc:date>2007-02-14T05:09:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to check whether a field is numeric</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-check-whether-a-field-is-numeric/m-p/3944238#M97587</link>
      <description>i have attached the file&lt;BR /&gt;i want the field no and record no&lt;BR /&gt;eg: print (NR,i)</description>
      <pubDate>Wed, 14 Feb 2007 05:21:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-check-whether-a-field-is-numeric/m-p/3944238#M97587</guid>
      <dc:creator>Pavitra</dc:creator>
      <dc:date>2007-02-14T05:21:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to check whether a field is numeric</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-check-whether-a-field-is-numeric/m-p/3944239#M97588</link>
      <description>Hi, base on your file, please show the output you need to better udnerstand your request. If I weel understood you want the record number and the filed number of those record where OR F4 OR F5 OR both are not numeric. Is it correct?&lt;BR /&gt;Rgds,&lt;BR /&gt;Art</description>
      <pubDate>Wed, 14 Feb 2007 05:56:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-check-whether-a-field-is-numeric/m-p/3944239#M97588</guid>
      <dc:creator>Arturo Galbiati</dc:creator>
      <dc:date>2007-02-14T05:56:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to check whether a field is numeric</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-check-whether-a-field-is-numeric/m-p/3944240#M97589</link>
      <description>&lt;!--!*#--&gt;Good question Arturo!&lt;BR /&gt;&lt;BR /&gt;Can there be comma's between the quotes?&lt;BR /&gt;&lt;BR /&gt;Check out: &lt;BR /&gt;&lt;A href="https://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1064324" target="_blank"&gt;https://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1064324&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; (not in perl pls) &lt;BR /&gt;&lt;BR /&gt;I always find that an intesting comment.&lt;BR /&gt;This is a relatively simple task, and very simple in perl. Apparently you do not know how to solve this yourself, so why would it matter what implementation language the solution would be in? Once you have the framwork, you'll will surely be able to figure out how to modify &amp;amp; maintain after minimal studying no matter what language!&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;perl -lne '@F=split /,/; for $i (4,5) { print qq(Line $. Field $i not numeric) if $F[$i-1] =~ /\D/}' tmp.txt&lt;BR /&gt;Line 3 Field 4 not numeric&lt;BR /&gt;Line 5 Field 5 not numeric&lt;BR /&gt;&lt;BR /&gt;-l             # l=new-line with prin&lt;BR /&gt;-n             # loop no print&lt;BR /&gt;-e             # program text follows&lt;BR /&gt;&lt;BR /&gt;@F=split /,/;  # split currenlt line ($_) into array F using commans as field delimitor&lt;BR /&gt; &lt;BR /&gt;for $i (4,5)   # list of fields to check&lt;BR /&gt;print qq(      # Alternative for quoted string&lt;BR /&gt;$. $i          # current line number and field&lt;BR /&gt;$F[$i-1]       # array element for field number&lt;BR /&gt; =~ /\D/       # string match for non-decimal (\d = decimal)&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 14 Feb 2007 07:17:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-check-whether-a-field-is-numeric/m-p/3944240#M97589</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-02-14T07:17:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to check whether a field is numeric</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-check-whether-a-field-is-numeric/m-p/3944241#M97590</link>
      <description>Hi,&lt;BR /&gt;based on this file:&lt;BR /&gt;/&amp;gt; cat f2&lt;BR /&gt;"ABC","RRRRR","AAAA",009,999&lt;BR /&gt;"ABC","RRRRR","AAAA",009,999&lt;BR /&gt;"PPC","PPPPP","AAA",X,1&lt;BR /&gt;"PPC","PPPPP","AAA",1,X&lt;BR /&gt;"PPC","PPPPP","AAA",Y,X&lt;BR /&gt;&lt;BR /&gt;and using this:&lt;BR /&gt;awk -F, '{if ($4 ~ /^[0-9]+$/) F4=4 ;else F4=" "&lt;BR /&gt;          if ($5 ~ /^[0-9]+$/) F5=5 ;else F5=" "&lt;BR /&gt;          print NR " " F4 " " F5}&lt;BR /&gt;        ' f2&lt;BR /&gt;&lt;BR /&gt;you get:&lt;BR /&gt;1 4 5&lt;BR /&gt;2 4 5&lt;BR /&gt;3   5&lt;BR /&gt;4 4  &lt;BR /&gt;5&lt;BR /&gt;&lt;BR /&gt;is it ok?&lt;BR /&gt;Rgds,&lt;BR /&gt;Art&lt;BR /&gt;</description>
      <pubDate>Wed, 14 Feb 2007 07:42:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-check-whether-a-field-is-numeric/m-p/3944241#M97590</guid>
      <dc:creator>Arturo Galbiati</dc:creator>
      <dc:date>2007-02-14T07:42:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to check whether a field is numeric</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-check-whether-a-field-is-numeric/m-p/3944242#M97591</link>
      <description>Hi Pavitra:&lt;BR /&gt;&lt;BR /&gt;I wholly second Hein's remarks regarding Perl.&lt;BR /&gt;&lt;BR /&gt;That said, here's yet another way using 'expr'.  The idea is to determine if a field consists only of numbers for the length of the field.  By example.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;F=`echo "111,222,333,444,5X5,666"|cut -d, -f4`&lt;BR /&gt;[ `expr "${F}" : '[0-9]*'` -eq `expr "${F}" : '.*'` ] \&lt;BR /&gt;    &amp;amp;&amp;amp; echo "numeric" || echo "not numeric"&lt;BR /&gt;&lt;BR /&gt;F=`echo "111,222,333,444,5X5,666"|cut -d, -f5`&lt;BR /&gt;[ `expr "${F}" : '[0-9]*'` -eq `expr "${F}" : '.*'` ] \&lt;BR /&gt;    &amp;amp;&amp;amp; echo "numeric" || echo "not numeric"&lt;BR /&gt;&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 14 Feb 2007 07:52:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-check-whether-a-field-is-numeric/m-p/3944242#M97591</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-02-14T07:52:52Z</dc:date>
    </item>
  </channel>
</rss>

