Computing.Net > Forums > Unix > Compare two variables in shell script

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Compare two variables in shell script

Reply to Message Icon

Name: Nash
Date: August 7, 2002 at 13:02:54 Pacific
Comment:

Can anyone help me with comparing two vaiables in unix shell script.

This is what i'm trying....

if [ $X -ne $Y ]
then
-----
else
----
fi

Where X and Y are varibles with diff values.

thanks in advance.
Nash




Sponsored Link
Ads by Google

Response Number 1
Name: Ned
Date: August 7, 2002 at 14:33:21 Pacific
Reply:

Use != instead of -ne
It works in both alpha and numeric values.


0

Response Number 2
Name: Nash
Date: August 8, 2002 at 05:47:56 Pacific
Reply:

It Worked!!!

Thanks Ned.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Compare two variables in shell script

awk variables in shell script www.computing.net/answers/unix/awk-variables-in-shell-script/6201.html

Variables in Shell SCripting www.computing.net/answers/unix/variables-in-shell-scripting/6020.html

use variable of shell script in awk www.computing.net/answers/unix/use-variable-of-shell-script-in-awk/4570.html