The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Negative Numbers for input parameters. Gussifinknottle UNIX for Dummies Questions & Answers 3 07-21-2009 12:30 AM
Regular expressions to check numbers with currency my_Perl Shell Programming and Scripting 7 06-16-2009 03:29 AM
check the input Shilpi UNIX for Dummies Questions & Answers 1 03-04-2008 08:26 AM
Accept user input - only numbers pvar Shell Programming and Scripting 1 02-10-2004 11:10 AM
Is there any way to makesure that the input from the user is all numbers? XXXXXXXXXX Shell Programming and Scripting 5 02-19-2002 07:13 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 10-01-2009
waso's Avatar
waso waso is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 9
Arrow [KSH] Check input numbers ??

script name is test.sh

user that is execute script must imput first parametar.
parametar is number betwen 1-12
number canot have zero 01,02... it must be 1,2,3

so i must check in script if is number betwen 1-12, and that parameter dosent have more then 2 numbers, and that numbers from 1-9 dosent have zero.

exemple of script execute:
Code:
test.sh 4
test.sh 11
for start i have something like this in my mind

Code:
#!/bin/sh

parameter=$1

#Check input parameters
if [ $# -ne 1 ]; then
            echo "wrong input"
            exit 1
fi

if [ $parameter >= 1 -o $parameter <= 12 ]
then
						echo "OK."
else
            echo "wrong input"
            exit 1
fi
thanks for help

Last edited by zaxxon; 10-01-2009 at 06:25 AM.. Reason: code tags
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:02 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0