De maneira mais elaborada
As sequências seguintes podem ajudar:
gnu:~$ [ sam -eq sam ]
bash: [: sam: integer expression expected
gnu:~$ echo "Exit status of \"[ sam -eq sam ]\" is $?."
Exit status of "[ sam -eq sam ]" is 2.
gnu:~$ [ 5 -eq 5 ]
gnu:~$ echo "Exit status of \"[ 5 -eq 5 ]\" is $?."
Exit status of "[ 5 -eq 5 ]" is 0.
gnu:~$ [ 5 = 5 ]
gnu:~$ echo "Exit status of \"[ 5 = 5 ]\" is $?."
Exit status of "[ 5 = 5 ]" is 0.
gnu:~$ [ sam = sam ]
gnu:~$ echo "Exit status of \"[ sam = sam ]\" is $?."
Exit status of "[ sam = sam ]" is 0.
gnu:~$ [ 5 == 5 ]
gnu:~$ echo "Exit status of \"[ 5 == 5 ]\" is $?."
Exit status of "[ 5 == 5 ]" is 0.
gnu:~$ [ sam == sam ]
gnu:~$ echo "Exit status of \"[ sam == sam ]\" is $?."
Exit status of "[ sam == sam ]" is 0.
gnu:~$ (( 5 == 5 ))
gnu:~$ echo "Exit status of \"(( 5 == 5 ))\" is $?."
Exit status of "(( 5 == 5 ))" is 0.
gnu:~$ (( sam == sam ))
gnu:~$ echo "Exit status of \"(( sam == sam ))\" is $?."
Exit status of "(( sam == sam ))" is 0.
gnu:~$ ( sam = sam )
The program 'sam' is currently not installed. You can install it by typing:
sudo apt-get install simon
gnu:~$ echo "Exit status of \"( sam = sam )\" is $?."
Exit status of "( sam = sam )" is 127.
gnu:~$ ( 5 = 5 )
5: command not found
gnu:~$ echo "Exit status of \"( 5 = 5 )\" is $?."
Exit status of "( 5 = 5 )" is 127.
gnu:~$ ( sam == sam )
The program 'sam' is currently not installed. You can install it by typing:
sudo apt-get install simon
gnu:~$ echo "Exit status of \"( sam == sam )\" is $?."
Exit status of "( sam == sam )" is 127.
gnu:~$ ( 5 == 5 )
5: command not found
gnu:~$ echo "Exit status of \"( 5 == 5 )\" is $?."
Exit status of "( 5 == 5 )" is 127.