2
我讀了c.learncodethehardway.org/book/ex28.html運算符「2 >>」在shell腳本中做了什麼?
echo "Running unit tests:"
for i in tests/*_tests
do
if test -f $i
then
if $VALGRIND ./$i 2>> tests/tests.log
then
echo $i PASS
else
echo "ERROR in test $i: here's tests/tests.log"
echo "------"
tail tests/tests.log
exit 1
fi
fi
done
echo ""
下面的代碼是什麼操作 「2 >>」 在shell腳本呢?
而且,之前我問這個問題,我已經測試了它的命令行,這就是我的了:
~/Projects/test> if 0 2>> hello.txt; then echo "0"; else echo "?"; fi
?
~/Projects/test> if 1 2>> hello.txt; then echo "0"; else echo "?"; fi
?
~/Projects/test> if 108230284 2>> hello.txt; then echo "0"; else echo "?"; fi
?
~/Projects/test> if 0 2>> hello.txt; then echo "0"; else echo "?"; fi
?
~/Projects/test> cat hello.txt
-bash: 0: command not found
-bash: 1: command not found
-bash: 108230284: command not found
-bash: 0: command not found
請參閱:http://www.linuxtopia.org/online_books/advanced_bash_scripting_guide/comparison-ops.html \ –