<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-8514572398266969701.post6477235244400152026..comments</id><updated>2011-11-23T16:23:06.332-08:00</updated><category term='Linux Fun'/><category term='Shell Scripts'/><category term='Article'/><category term='HowTo&apos;s'/><category term='Beginners Scripts'/><title type='text'>Comments on UNIX/Linux Bash Shell Scripting: How to Validate Integer Input using Shell script</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.bashguru.com/feeds/6477235244400152026/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8514572398266969701/6477235244400152026/comments/default'/><link rel='alternate' type='text/html' href='http://www.bashguru.com/2010/12/how-to-validate-integer-input-using.html'/><author><name>venu k</name><uri>http://www.blogger.com/profile/15099300607950419203</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8514572398266969701.post-5321798008108487058</id><published>2011-11-23T16:23:06.332-08:00</published><updated>2011-11-23T16:23:06.332-08:00</updated><title type='text'>Samples:
Test numeric &amp;#39;foo&amp;#39;
No: foo
Test n...</title><content type='html'>Samples:&lt;br /&gt;Test numeric &amp;#39;foo&amp;#39;&lt;br /&gt;No: foo&lt;br /&gt;Test numeric &amp;#39;2&amp;#39;&lt;br /&gt;Yes: 2&lt;br /&gt;Test numeric &amp;#39;-7&amp;#39;&lt;br /&gt;Yes: -7&lt;br /&gt;Test numeric &amp;#39;+8&amp;#39;&lt;br /&gt;Yes: 8&lt;br /&gt;Test numeric &amp;#39;2**7&amp;#39;&lt;br /&gt;Yes: 128&lt;br /&gt;Test numeric &amp;#39;3+4+5&amp;#39;&lt;br /&gt;Yes: 12&lt;br /&gt;Test numeric &amp;#39;20%14&amp;#39;&lt;br /&gt;Yes: 6&lt;br /&gt;Test numeric &amp;#39;+&amp;#39;&lt;br /&gt;No: +&lt;br /&gt;Test numeric &amp;#39;-&amp;#39;&lt;br /&gt;No: -&lt;br /&gt;Test numeric &amp;#39;%&amp;#39;&lt;br /&gt;No: %</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8514572398266969701/6477235244400152026/comments/default/5321798008108487058'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8514572398266969701/6477235244400152026/comments/default/5321798008108487058'/><link rel='alternate' type='text/html' href='http://www.bashguru.com/2010/12/how-to-validate-integer-input-using.html?showComment=1322094186332#c5321798008108487058' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.bashguru.com/2010/12/how-to-validate-integer-input-using.html' ref='tag:blogger.com,1999:blog-8514572398266969701.post-6477235244400152026' source='http://www.blogger.com/feeds/8514572398266969701/posts/default/6477235244400152026' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1200515682'/></entry><entry><id>tag:blogger.com,1999:blog-8514572398266969701.post-7816879443417537499</id><published>2011-11-23T16:19:03.584-08:00</published><updated>2011-11-23T16:19:03.584-08:00</updated><title type='text'>the ultimate numeric testing:

#!/bin/bash

n=&amp;quo...</title><content type='html'>the ultimate numeric testing:&lt;br /&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;&lt;br /&gt;n=&amp;quot;$1&amp;quot;&lt;br /&gt;&lt;br /&gt;echo &amp;quot;Test numeric &amp;#39;$n&amp;#39; &amp;quot;&lt;br /&gt;if ((n)) 2&amp;gt;/dev/null; then&lt;br /&gt;   n=$((n))&lt;br /&gt;   echo &amp;quot;Yes: $n&amp;quot;&lt;br /&gt;else&lt;br /&gt;   echo &amp;quot;No: $n&amp;quot;&lt;br /&gt;fi</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8514572398266969701/6477235244400152026/comments/default/7816879443417537499'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8514572398266969701/6477235244400152026/comments/default/7816879443417537499'/><link rel='alternate' type='text/html' href='http://www.bashguru.com/2010/12/how-to-validate-integer-input-using.html?showComment=1322093943584#c7816879443417537499' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.bashguru.com/2010/12/how-to-validate-integer-input-using.html' ref='tag:blogger.com,1999:blog-8514572398266969701.post-6477235244400152026' source='http://www.blogger.com/feeds/8514572398266969701/posts/default/6477235244400152026' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1200515682'/></entry><entry><id>tag:blogger.com,1999:blog-8514572398266969701.post-4214124106666299298</id><published>2011-03-30T05:17:32.031-07:00</published><updated>2011-03-30T05:17:32.031-07:00</updated><title type='text'>From Method 1, how would I adapt

if [ $Number -ne...</title><content type='html'>From Method 1, how would I adapt&lt;br /&gt;&lt;br /&gt;if [ $Number -ne 0 -o $Number -eq 0 2&amp;gt;/dev/null ]&lt;br /&gt;&lt;br /&gt;so that it worked in a while loop so that I could keep prompting the user for a number until they entered one?</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8514572398266969701/6477235244400152026/comments/default/4214124106666299298'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8514572398266969701/6477235244400152026/comments/default/4214124106666299298'/><link rel='alternate' type='text/html' href='http://www.bashguru.com/2010/12/how-to-validate-integer-input-using.html?showComment=1301487452031#c4214124106666299298' title=''/><author><name>Andrew</name><uri>http://www.blogger.com/profile/12782111793275332410</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.bashguru.com/2010/12/how-to-validate-integer-input-using.html' ref='tag:blogger.com,1999:blog-8514572398266969701.post-6477235244400152026' source='http://www.blogger.com/feeds/8514572398266969701/posts/default/6477235244400152026' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1424799376'/></entry><entry><id>tag:blogger.com,1999:blog-8514572398266969701.post-5864510576096515876</id><published>2011-01-07T08:03:31.045-08:00</published><updated>2011-01-07T08:03:31.045-08:00</updated><title type='text'>Hi Bond,

Your idea is good, but above script has ...</title><content type='html'>Hi Bond,&lt;br /&gt;&lt;br /&gt;Your idea is good, but above script has a mistake.&lt;br /&gt;&lt;br /&gt;$ sh validintegernum.sh -12-12&lt;br /&gt;&lt;br /&gt;Script to validate whether input is an Integer value of not&lt;br /&gt;code: 45&lt;br /&gt;code: 49&lt;br /&gt;code: 50&lt;br /&gt;code: 45&lt;br /&gt;code: 49&lt;br /&gt;code: 50&lt;br /&gt;&lt;br /&gt;The input is valid integer value&lt;br /&gt;&lt;br /&gt;It accepts hyphen any where. I rectified it and posted as method 3.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8514572398266969701/6477235244400152026/comments/default/5864510576096515876'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8514572398266969701/6477235244400152026/comments/default/5864510576096515876'/><link rel='alternate' type='text/html' href='http://www.bashguru.com/2010/12/how-to-validate-integer-input-using.html?showComment=1294416211045#c5864510576096515876' title=''/><author><name>venu k</name><uri>http://www.blogger.com/profile/15099300607950419203</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.bashguru.com/2010/12/how-to-validate-integer-input-using.html' ref='tag:blogger.com,1999:blog-8514572398266969701.post-6477235244400152026' source='http://www.blogger.com/feeds/8514572398266969701/posts/default/6477235244400152026' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1903829714'/></entry><entry><id>tag:blogger.com,1999:blog-8514572398266969701.post-815502909393429261</id><published>2011-01-03T01:57:29.321-08:00</published><updated>2011-01-03T01:57:29.321-08:00</updated><title type='text'>Hi Venu,

Just another version to server the same ...</title><content type='html'>Hi Venu,&lt;br /&gt;&lt;br /&gt;Just another version to server the same purpose using comparison with ASCII chart:&lt;br /&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;&lt;br /&gt;echo -e &amp;quot;\nScript to validate whether input is an Interger value of not&amp;quot;&lt;br /&gt;&lt;br /&gt;if [ $# -ne 1 ]&lt;br /&gt;then&lt;br /&gt; echo &amp;quot;Usage: $0 [Input Value to be validated]&amp;quot;&lt;br /&gt; exit&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;str=&amp;quot;$1&amp;quot;&lt;br /&gt;cnt=${#str}    # Counting the length of string fetched&lt;br /&gt;&lt;br /&gt;for ((i=0; i &amp;lt; cnt; i++))&lt;br /&gt;do&lt;br /&gt; char=${str:$i:1}  # Reading one character at a time from the input string&lt;br /&gt;&lt;br /&gt; code=`printf &amp;#39;%d&amp;#39; &amp;quot;&amp;#39;$char&amp;quot;` # Echo the ASCII value of character&lt;br /&gt;&lt;br /&gt; echo &amp;quot;code: &amp;quot; $code&lt;br /&gt; if [ $code -lt 48 ] || [ $code -gt 57 ]  # Comparing the ASCII value range of Intergers ( 48 - 57 )&lt;br /&gt; then&lt;br /&gt;  if [ $code -ne 45 ]   # To accept the negative integer value as well&lt;br /&gt;  then&lt;br /&gt;   echo -e &amp;quot;Input is not an integer value\n&amp;quot;&lt;br /&gt;   exit&lt;br /&gt;  fi&lt;br /&gt; fi&lt;br /&gt;done&lt;br /&gt;&lt;br /&gt;echo -e &amp;quot;\nThe input is valid integer value\n&amp;quot;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8514572398266969701/6477235244400152026/comments/default/815502909393429261'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8514572398266969701/6477235244400152026/comments/default/815502909393429261'/><link rel='alternate' type='text/html' href='http://www.bashguru.com/2010/12/how-to-validate-integer-input-using.html?showComment=1294048649321#c815502909393429261' title=''/><author><name>b0nd</name><uri>http://www.blogger.com/profile/16301278806252131564</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.bashguru.com/2010/12/how-to-validate-integer-input-using.html' ref='tag:blogger.com,1999:blog-8514572398266969701.post-6477235244400152026' source='http://www.blogger.com/feeds/8514572398266969701/posts/default/6477235244400152026' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1064441446'/></entry></feed>
