![]() |
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 |
| IF Statement | koti_rama | Shell Programming and Scripting | 3 | 04-29-2008 04:48 AM |
| If statement - How to write a null statement | april | Shell Programming and Scripting | 3 | 04-16-2008 01:14 PM |
| using && in if statement .. | jisha | Shell Programming and Scripting | 7 | 02-01-2008 07:52 AM |
| IF statement on a df -g | hassanj | UNIX for Advanced & Expert Users | 1 | 12-18-2007 07:41 AM |
| If statement | mariner | UNIX for Advanced & Expert Users | 4 | 12-16-2004 07:21 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
if statement
Hi,
how to write an if statement for values in between if [$? -ne 0];then fi here I want to write an if statement if $? is inbetween 1 and 126 how to write this if [$? inbetween 1 and 126];then fi I'd also like to know the difference between the following two if statements if [$? -ne 0];then fi and if [[$? -ne 0]];then fi Thanks for your time. Ram |
|
||||
|
Quote:
To do an "in between" test with any of the above you need to use AND or OR depending on which way round you do it. AND is && and OR is || e.g. if [ $val -lt 127 ] && [ $val -gt 0 ] then ...... fi there might be niftier ways with some shells (like doing the && or || inside a single test ) but it depends what you are using. |
|
||||
|
Quote:
Code:
[ condition1 -a condition2 ] [ condition1 -o condition2 ] Code:
[wiki] condition1 && condition2 [/wiki] [wiki] condition1 || condition2 [/wiki] Regards |
|
||||
|
The Bourne syntax is still valid in Korn, but not vice versa. In other words, Korn shell is backwards-compatible with the "classic" Bourne shell.
Just for completeness, [ test1 ] && [ test2 ] is valid Bourne syntax too. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|