Visit Our UNIX and Linux User Community


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

 

Previous Thread | Next Thread
Test Your Knowledge in Computers #819
Difficulty: Medium
In CSS, E ~ F matches an F element preceded by an E element.
True or False?

Featured Tech Videos