[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
The usage of [[ (not with if)
From: |
Peng Yu |
Subject: |
The usage of [[ (not with if) |
Date: |
Wed, 4 Aug 2010 10:03:25 -0500 |
Hello All,
I have the following script and output. The man page says "Return a
status of 0 or 1 depending on the evaluation of the conditional
expression expression." Therefore, I thought that the two printf
statements should print 1 and 0 respectively. But both of them print
0. I'm wondering what [[ should return if it is not used with a if
statement.
$ cat main.sh
#!/usr/bin/env bash
printf '%d\n' `[[ 10 -gt 1 ]]`
printf '%d\n' `[[ 1 -gt 10 ]]`
if [[ 10 -gt 1 ]]
then
echo xxx
fi
$ ./main.sh
0
0
xxx
--
Regards,
Peng
- The usage of [[ (not with if),
Peng Yu <=