8
有什么区别,如果有的话,在以下两个bash的评价:在bash,什么是之间的差异[测试1 && test2的] VS [测试1]] && [TEST2]
if [[ -s $file1 && $file1 -nt $file2 ]]; then
if [[ -s $file1 ]] && [[ $file1 -nt $file2 ]]; then
有什么区别,如果有的话,在以下两个bash的评价:在bash,什么是之间的差异[测试1 && test2的] VS [测试1]] && [TEST2]
if [[ -s $file1 && $file1 -nt $file2 ]]; then
if [[ -s $file1 ]] && [[ $file1 -nt $file2 ]]; then
没有区别。它们在功能上是相同的。
一个有趣的不谈,如果你使用的[
代替[[
,实际上是一个检测的差异的原因被评价的顺序:
[ -s "$file1" -a "$file1" -nt "$(echo side effect >&2)" ]
[ -s "$file1" ] && [ "$file1" -nt "$(echo side effect >&2)" ]
在这种情况下,第一行会打印“的一面效应“,而第二个不会。
但是,这只是[
的情况,而不是[[ ]]
。