![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| if statement | ramky79 | Shell Programming and Scripting | 6 | 05-29-2008 12:17 AM |
| IF Statement | koti_rama | Shell Programming and Scripting | 3 | 04-29-2008 01:48 AM |
| If statement - How to write a null statement | april | Shell Programming and Scripting | 3 | 04-16-2008 10:14 AM |
| IF statement on a df -g | hassanj | UNIX for Advanced & Expert Users | 1 | 12-18-2007 03:41 AM |
| If statement | mariner | UNIX for Advanced & Expert Users | 4 | 12-16-2004 03:21 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi All,
Can some one tell me how to get run the following: data1="hello" data2="world" if [ "$data2" != "world" && "$data1" != "hello"] then { echo "good afternnon" } else { echo " good morning" } fi The above code gives me an error ad below : ./if.h: line 3: [: missing `]' Thanks in advance Js |
| Forum Sponsor | ||
|
|
|
|||
|
Don't forget to let a space before ] and after [ !
Here is the code : Code:
data1="hello"
data2="world"
if [ "$data2" != "world" ] && [ "$data1" != "hello" ]
then
{
echo "good afternnon"
}
else
{
echo " good morning"
}
fi
|
|
|||
|
If you want to make your schell script more efficient you should use the shell builtins
Code:
#!/usr/bin/ksh
data1="hello"
data2="world"
if [[ "$data2" != "world" && "$data1" != "hello" ]]
then
print "good afternnon"
else
print "good morning"
fi
|
|||
| Google UNIX.COM |
| Thread Tools | |
| Display Modes | |
|
|