- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: entering charcter or numerical value then chec...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-02-2009 08:23 AM
тАО06-02-2009 08:23 AM
Re: entering charcter or numerical value then checking
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-02-2009 08:25 AM
тАО06-02-2009 08:25 AM
Re: entering charcter or numerical value then checking
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-02-2009 08:27 AM
тАО06-02-2009 08:27 AM
Re: entering charcter or numerical value then checking
> 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.
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.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-02-2009 08:31 AM
тАО06-02-2009 08:31 AM
Re: entering charcter or numerical value then checking
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
it appears that you missed some whitespace around the "%", but its hard to tell in the posts
original was:
...
result=$(($num % 2))
if [ $result -eq 0 ]
....
you posted:
...
the "result=$(($num %2))
if[$result -eq 0]
...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-02-2009 08:42 AM
тАО06-02-2009 08:42 AM
Re: entering charcter or numerical value then checking
I meant to say "Yes, in principle". You see the _principal_ users here are professionals with professional needs, not students doing homework.
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-02-2009 09:02 AM
тАО06-02-2009 09:02 AM
Re: entering charcter or numerical value then checking
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.
ksh tends to port well from unix to linux, and visa versa.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-02-2009 09:03 AM
тАО06-02-2009 09:03 AM
Re: entering charcter or numerical value then checking
(I'll ask the moderators to move it there with your other thread.)
>OldSchool: original was:
>result=$(($num % 2))
There is no need to use "$" within (( )) or $(( )).
(( result = num % 2 ))
In fact, you can replace the original by:
if (( number % 2 == 0 )); then
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-02-2009 10:46 PM
тАО06-02-2009 10:46 PM
Re: entering charcter or numerical value then checking
awk 'BEGIN{
while(1){
printf "Enter a numerical number: "
getline number < "/dev/stdin"
if (number+0==number){
print "yes, a number"
break
}else{
print "no, not a number. Enter again"
}
}
print "number is " number
if ( number %2 == 0 ){
print "Number "number" is even"
}else{
print "Number "number" is odd"
}
}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-03-2009 08:23 AM
тАО06-03-2009 08:23 AM
Re: entering charcter or numerical value then checking
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-03-2009 06:35 PM
тАО06-03-2009 06:35 PM