|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | 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. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to use "not equal to " in IF statement
Hi,
i need to compare two variables by using if statement if [ $var1 -ne $var2 ] then echo "$var1" else echo "$var2" fi where -ne is used for not equal to but this is not working and giving me a syntax error. can anybody tel me how use not equal to with 'if' in ksh thanks |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Code:
if [ $var1 != $var2 ] then echo "$var1" else echo "$var2" fi |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
thanks Ikon.... it's working fine now..
![]() |
|
#4
|
||||
|
||||
|
try to do it in KSH....
#!/bin/ksh if [[ "$var1" -ne "$var2" ]] ; then echo "$var1" else echo "$var2" fi |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| What is the meaning of "-s" option in "if" statement? | rymnd_12345 | UNIX for Dummies Questions & Answers | 7 | 05-03-2012 12:22 PM |
| awk command to replace ";" with "|" and ""|" at diferent places in line of file | shis100 | Shell Programming and Scripting | 7 | 03-16-2011 08:59 AM |
| What "-a" operator means in "if" statement | aoussenko | Shell Programming and Scripting | 1 | 03-02-2011 10:30 AM |
| "if" and "then" statement is not working in RedHat | Afi_Linux | Red Hat | 10 | 01-28-2011 03:26 AM |
|
|