![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| Plz correct my syntax of shell script | girish.batra | Shell Programming and Scripting | 2 | 06-06-2008 06:36 AM |
| Shell Script syntax for XML processing | vignesh53 | Shell Programming and Scripting | 5 | 02-05-2008 03:21 AM |
| need a quick basic shell script help | eb222 | Shell Programming and Scripting | 6 | 11-22-2007 09:00 AM |
| Shell script syntax checker | handak9 | Shell Programming and Scripting | 2 | 07-16-2004 03:56 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Basic Shell script syntax help
Hi All,
I am new to shell scripting. I have a variable which holds a numeric value.I have to check whether this variable holds a value between(0- 8),(8-17)(17-24).How do i write this syntax using if in shell scripting. Thanks Vignesh |
|
||||
|
Usage of IF/Case statements...*
IF u want to use if-Syntax[ksh],
if [ $ur_variable -ge 0 ] && [ $ur_variable -le 8 ] then echo "Num is between 0-8" elif [ $ur_variable -ge 0 ] && [ $ur_variable -le 8 ] then echo "Num is between 9-17" elif [ $ur_variable -ge 0 ] && [ $ur_variable -le 8 ] then echo "Num is between 18-24" fi Use case for your problem... case $ur_variable "") echo "Not entered" [0-8]) echo "Num is between 0-8";break; [9-17]) echo "Num is between 9-17";break; [18-24]) echo "Num is between 18-24";break; *) echo "Non-Numeric or Alphabetic or Spl,chars or Not in range[0-24];break; esac |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|