help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

not sure about number comparison


From: winnie hw
Subject: not sure about number comparison
Date: Sun, 19 Feb 2023 08:44:12 +0800

Hello,

I am a bit confused about the following 4 statements.

$ if [ $(id -u) -ne 0 ];then echo true;fi
true

$ if [ $(id -u) != 0 ];then echo true;fi
true

$ if [[ $(id -u) -ne 0 ]];then echo true;fi
true

$ if [[ $(id -u) != 0 ]];then echo true;fi
true

$ echo $SHELL
/bin/bash

My questions are:

1. for number comparison, when to use "-ne" and when to use "!="?

2. For the above operations, what's the difference between [ .. ] and [[ ..
]]?


Thank you.
winnie


reply via email to

[Prev in Thread] Current Thread [Next in Thread]