when to use -ne and when to use !=


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers when to use -ne and when to use !=
# 1  
Old 08-12-2009
when to use -ne and when to use !=

Hi guys,
Its a simple question in if loop when shouid i use -ne and when should i use !=
please explain.

thanks,
ram.
# 2  
Old 08-12-2009
In BASH:

-ne Integer comparison
!= String comparison

Other Comparison Operators
# 3  
Old 08-13-2009
Nowadays the '-ne" form of binary arithmetic operator is generally regarded as depricated.
Code:
#!/usr/local/bin/bash

if [[ 4 != 5 ]]
then
   echo "true"
fi
if [[ 4 -ne 5 ]]
then
   echo "true"
fi

 
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question