<?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: entering charcter or numerical value then checking in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431284#M61491</link>
    <description>there are a variety of shell tutorials available.  parker's site is useful, as is shelldorado.&lt;BR /&gt;&lt;BR /&gt;one thing I would caution you about is learning scripting on linux (ie. bash) and then attempting to use unix.  the "linuxy" gnu extensions that you will come to expect simply won't be there.&lt;BR /&gt;&lt;BR /&gt;ksh tends to port well from unix to linux, and visa versa.</description>
    <pubDate>Tue, 02 Jun 2009 16:02:33 GMT</pubDate>
    <dc:creator>OldSchool</dc:creator>
    <dc:date>2009-06-02T16:02:33Z</dc:date>
    <item>
      <title>entering charcter or numerical value then checking</title>
      <link>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431269#M61476</link>
      <description>Write a shell script to find even or odd, and print out the result.&lt;BR /&gt;&lt;BR /&gt;This should include 2 portions:&lt;BR /&gt;&lt;BR /&gt;Ask user to input a numerical number, then the script should check if it is a character or numerical, ask user re-enter a numerical number, if character found.&lt;BR /&gt;&lt;BR /&gt;If it is an numerical digit, find out even or odd, and print out the result &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;this is what I got:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!bin/bash&lt;BR /&gt;echo -e "Please enter a numerical number --&amp;gt; \c"&lt;BR /&gt;read NUMBER&lt;BR /&gt;&lt;BR /&gt;mychar=1&lt;BR /&gt;if echo -e "$mychar | grep [a-z]"&lt;BR /&gt;then&lt;BR /&gt;echo -e "Please re-enter a numerical number --&amp;gt; \c"&lt;BR /&gt;read NUMBER&lt;BR /&gt;&lt;BR /&gt;if [ $(($number % 2)) -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;echo -e "$number is even even number"&lt;BR /&gt;else&lt;BR /&gt;echo -e "$number is an odd number"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;... am i doing something wrong. I'm assuming so. Any help would be awesome!&lt;BR /&gt;</description>
      <pubDate>Tue, 02 Jun 2009 14:22:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431269#M61476</guid>
      <dc:creator>lcpdl87</dc:creator>
      <dc:date>2009-06-02T14:22:19Z</dc:date>
    </item>
    <item>
      <title>Re: entering charcter or numerical value then checking</title>
      <link>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431270#M61477</link>
      <description>your script is missing some stuff.&lt;BR /&gt;&lt;BR /&gt;do you want the user to be forced to enter a numeric value or do you want him to exit the script with a non-zero return value, if he/she doesn't enter a numeric ?&lt;BR /&gt;&lt;BR /&gt;depending on the answer, you either will need an endless loop to check until a numeric value was entered around the first if block, something like:&lt;BR /&gt;&lt;BR /&gt;numeric_flag=0&lt;BR /&gt;while [ ${numeric_flag} -eq 0 ]&lt;BR /&gt;do&lt;BR /&gt;# check for alphabetic characters here&lt;BR /&gt;# if numeric value entered set numeric_flag to 1&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;otherwise, &lt;BR /&gt;&lt;BR /&gt;if non numeric value was found&lt;BR /&gt;&lt;BR /&gt;exit 1&lt;BR /&gt;&lt;BR /&gt;This should be a starting point for your debugging&lt;BR /&gt;</description>
      <pubDate>Tue, 02 Jun 2009 14:29:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431270#M61477</guid>
      <dc:creator>Mel Burslan</dc:creator>
      <dc:date>2009-06-02T14:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: entering charcter or numerical value then checking</title>
      <link>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431271#M61478</link>
      <description>I want the user to enter a "numerical number" like it says in the directions and if they enter an "a-z" character like a charcater in the alphabetic, then it should go down to "please re-enter another number" and then if someone enters 0-9.. it reads whether the number is odd or even.&lt;BR /&gt;&lt;BR /&gt;And obviously if the person enters a "0-9" on the first try, the programs read sthat and figures out if its odd or even right away.</description>
      <pubDate>Tue, 02 Jun 2009 14:45:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431271#M61478</guid>
      <dc:creator>lcpdl87</dc:creator>
      <dc:date>2009-06-02T14:45:07Z</dc:date>
    </item>
    <item>
      <title>Re: entering charcter or numerical value then checking</title>
      <link>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431272#M61479</link>
      <description>actually, let me re-phrase it, it has a lot of mistakes, like variables being assigned in upper case whereas getting checked in lower case. You are not using a mainframe or DOS or an archaic high level language which is case insensitive. In unix $NUMBER is not equal to $number which is not equal to $NuMbEr.&lt;BR /&gt;&lt;BR /&gt;here is the script you are looking for:&lt;BR /&gt;&lt;BR /&gt;r=0&lt;BR /&gt;while [ $r -eq 0 ]&lt;BR /&gt;do&lt;BR /&gt;clear&lt;BR /&gt;echo "enter numeric value"&lt;BR /&gt;read num&lt;BR /&gt;echo $num | grep -q [a-z]&lt;BR /&gt;r=${?}&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;result=$(($num % 2))&lt;BR /&gt;if [ $result -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;echo "\n\nthe number you entered was $num and it is an even number\n\n"&lt;BR /&gt;else&lt;BR /&gt;echo "\n\nthe number you entered was $num and it is an odd number\n\n"&lt;BR /&gt;fi&lt;BR /&gt;</description>
      <pubDate>Tue, 02 Jun 2009 14:45:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431272#M61479</guid>
      <dc:creator>Mel Burslan</dc:creator>
      <dc:date>2009-06-02T14:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: entering charcter or numerical value then checking</title>
      <link>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431273#M61480</link>
      <description>well, &lt;BR /&gt;&lt;BR /&gt;the "result=$(($num %2))&lt;BR /&gt;if[$result -eq 0]&lt;BR /&gt;&lt;BR /&gt;is giving me an error..&lt;BR /&gt;&lt;BR /&gt;syntax error: operand expected (error token is "%2")&lt;BR /&gt;then..&lt;BR /&gt;if [-eq 0]: command not found&lt;BR /&gt;syntax error near unexpected then</description>
      <pubDate>Tue, 02 Jun 2009 14:59:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431273#M61480</guid>
      <dc:creator>lcpdl87</dc:creator>
      <dc:date>2009-06-02T14:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: entering charcter or numerical value then checking</title>
      <link>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431274#M61481</link>
      <description>&lt;!--!*#--&gt;&amp;gt; Write a shell script to find even or odd,&lt;BR /&gt;&amp;gt; and print out the result.&lt;BR /&gt;&lt;BR /&gt;Sure sounds like homework to me.</description>
      <pubDate>Tue, 02 Jun 2009 15:06:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431274#M61481</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2009-06-02T15:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: entering charcter or numerical value then checking</title>
      <link>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431275#M61482</link>
      <description>No, its extra credit, and I believe I have most of it now but I'm still getting errors.</description>
      <pubDate>Tue, 02 Jun 2009 15:09:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431275#M61482</guid>
      <dc:creator>lcpdl87</dc:creator>
      <dc:date>2009-06-02T15:09:32Z</dc:date>
    </item>
    <item>
      <title>Re: entering charcter or numerical value then checking</title>
      <link>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431276#M61483</link>
      <description>extra credit is still homework or course study of some sort and instead of copying someone else's work, you should be doing your own investigation. If I were to know/think about this, I would not be writing the script for you previously. I know the script above works on a hpux 11.11 machine. I can see where you are going wrong but will not tell you :) It would otherwise take the whole fun out.&lt;BR /&gt;&lt;BR /&gt;Good luck</description>
      <pubDate>Tue, 02 Jun 2009 15:15:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431276#M61483</guid>
      <dc:creator>Mel Burslan</dc:creator>
      <dc:date>2009-06-02T15:15:45Z</dc:date>
    </item>
    <item>
      <title>Re: entering charcter or numerical value then checking</title>
      <link>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431277#M61484</link>
      <description>Well, if I wasn't stuck, I wouldn't even bother checking this site for help. It's a forum, you post your problem and people help you out. That's how a forum works doesn't it? And I've been looking through the book I was given and on the internet and I'm not finding any accurate results that could help me out in the slightest bit. All I wanted was some guidance.</description>
      <pubDate>Tue, 02 Jun 2009 15:19:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431277#M61484</guid>
      <dc:creator>lcpdl87</dc:creator>
      <dc:date>2009-06-02T15:19:13Z</dc:date>
    </item>
    <item>
      <title>Re: entering charcter or numerical value then checking</title>
      <link>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431278#M61485</link>
      <description>And I'm working with Linux 10, not whatever you're talking about.</description>
      <pubDate>Tue, 02 Jun 2009 15:20:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431278#M61485</guid>
      <dc:creator>lcpdl87</dc:creator>
      <dc:date>2009-06-02T15:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: entering charcter or numerical value then checking</title>
      <link>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431279#M61486</link>
      <description>Then maybe, instead of blindly posting questions in other UNIX platforms' forums, like HPUX here, you might want to try some linux forum. Huh ?</description>
      <pubDate>Tue, 02 Jun 2009 15:23:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431279#M61486</guid>
      <dc:creator>Mel Burslan</dc:creator>
      <dc:date>2009-06-02T15:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: entering charcter or numerical value then checking</title>
      <link>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431280#M61487</link>
      <description>and extra credit is not homework. it's something you choose to do if you more points to your grade and its OPTIONAL. it's not actual homework. homework is required to get the grade. I'm just trying to do this to boost my grade up alittle.</description>
      <pubDate>Tue, 02 Jun 2009 15:25:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431280#M61487</guid>
      <dc:creator>lcpdl87</dc:creator>
      <dc:date>2009-06-02T15:25:19Z</dc:date>
    </item>
    <item>
      <title>Re: entering charcter or numerical value then checking</title>
      <link>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431281#M61488</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Well, if I wasn't stuck, I wouldn't even bother checking this site for help. It's a forum, you post your problem and people help you out.&lt;BR /&gt;&lt;BR /&gt;Yes, in principal.  However, this community is intended to be for professionals dealing with professional problems, not for homework questions.  You are more than welcome to lurk and learn.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 02 Jun 2009 15:27:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431281#M61488</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-06-02T15:27:43Z</dc:date>
    </item>
    <item>
      <title>Re: entering charcter or numerical value then checking</title>
      <link>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431282#M61489</link>
      <description>&lt;!--!*#--&gt;"No, its extra credit, ..."  that's homework&lt;BR /&gt;&lt;BR /&gt;the version Mel posted works just fine w/ ksh and sh (after adding quotes around the []), has a few issues w/ echo in bash and dash&lt;BR /&gt;&lt;BR /&gt;it appears that you missed some whitespace around the "%", but its hard to tell in the posts&lt;BR /&gt;&lt;BR /&gt;original was:&lt;BR /&gt;...&lt;BR /&gt;result=$(($num % 2))&lt;BR /&gt;if [ $result -eq 0 ]&lt;BR /&gt;....&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;you posted:&lt;BR /&gt;...&lt;BR /&gt;the "result=$(($num %2))&lt;BR /&gt;if[$result -eq 0]&lt;BR /&gt;...</description>
      <pubDate>Tue, 02 Jun 2009 15:31:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431282#M61489</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2009-06-02T15:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: entering charcter or numerical value then checking</title>
      <link>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431283#M61490</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;I meant to say "Yes, in principle".  You see the _principal_ users here are professionals with professional needs, not students doing homework.&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 02 Jun 2009 15:42:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431283#M61490</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-06-02T15:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: entering charcter or numerical value then checking</title>
      <link>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431284#M61491</link>
      <description>there are a variety of shell tutorials available.  parker's site is useful, as is shelldorado.&lt;BR /&gt;&lt;BR /&gt;one thing I would caution you about is learning scripting on linux (ie. bash) and then attempting to use unix.  the "linuxy" gnu extensions that you will come to expect simply won't be there.&lt;BR /&gt;&lt;BR /&gt;ksh tends to port well from unix to linux, and visa versa.</description>
      <pubDate>Tue, 02 Jun 2009 16:02:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431284#M61491</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2009-06-02T16:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: entering charcter or numerical value then checking</title>
      <link>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431285#M61492</link>
      <description>&amp;gt;I'm working with Linux 10&lt;BR /&gt;&lt;BR /&gt;(I'll ask the moderators to move it there with your other thread.)&lt;BR /&gt;&lt;BR /&gt;&amp;gt;OldSchool: original was:&lt;BR /&gt;&amp;gt;result=$(($num % 2))&lt;BR /&gt;&lt;BR /&gt;There is no need to use "$" within (( )) or $(( )).&lt;BR /&gt;(( result = num % 2 ))&lt;BR /&gt;&lt;BR /&gt;In fact, you can replace the original by:&lt;BR /&gt;if (( number % 2 == 0 )); then&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 02 Jun 2009 16:03:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431285#M61492</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-06-02T16:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: entering charcter or numerical value then checking</title>
      <link>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431286#M61493</link>
      <description>&lt;!--!*#--&gt;#!/bin/bash&lt;BR /&gt;awk 'BEGIN{&lt;BR /&gt; while(1){&lt;BR /&gt;    printf "Enter a numerical number: "&lt;BR /&gt;    getline number &amp;lt; "/dev/stdin"&lt;BR /&gt;    if (number+0==number){&lt;BR /&gt;        print "yes, a number"&lt;BR /&gt;        break&lt;BR /&gt;    }else{&lt;BR /&gt;        print "no, not a number. Enter again"    &lt;BR /&gt;    }&lt;BR /&gt; }&lt;BR /&gt; print "number is " number&lt;BR /&gt; if ( number %2 == 0 ){&lt;BR /&gt;    print "Number "number" is even"&lt;BR /&gt; }else{&lt;BR /&gt;    print "Number "number" is odd"&lt;BR /&gt; }&lt;BR /&gt;}'</description>
      <pubDate>Wed, 03 Jun 2009 05:46:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431286#M61493</guid>
      <dc:creator>ghostdog74</dc:creator>
      <dc:date>2009-06-03T05:46:45Z</dc:date>
    </item>
    <item>
      <title>Re: entering charcter or numerical value then checking</title>
      <link>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431287#M61494</link>
      <description>I tested that. That makes it say there's no file or directory for the file.</description>
      <pubDate>Wed, 03 Jun 2009 15:23:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431287#M61494</guid>
      <dc:creator>lcpdl87</dc:creator>
      <dc:date>2009-06-03T15:23:05Z</dc:date>
    </item>
    <item>
      <title>Re: entering charcter or numerical value then checking</title>
      <link>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431288#M61495</link>
      <description>it works fine for me.</description>
      <pubDate>Thu, 04 Jun 2009 01:35:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/entering-charcter-or-numerical-value-then-checking/m-p/4431288#M61495</guid>
      <dc:creator>ghostdog74</dc:creator>
      <dc:date>2009-06-04T01:35:51Z</dc:date>
    </item>
  </channel>
</rss>

