2
我有以下兩塊代碼,我不太清楚什麼是$?和$#代表。請幫忙。
一個代碼
#!/bin/bashUSERID="$1"
/bin/id $USERID 2>/dev/null
[ $? -eq 0 ] && echo "User found" || echo "User not found"
/bin/id -g $USERID 2>/dev/null
[ $? -eq 0 ] && echo "Group found" || echo "Group not found" `
$ cat > mtable
兩個代碼
#!/bin/sh
#
#Script to test for loop
#
#
if [ $# -eq 0 ]
then
echo "Error - Number missing form command line argument"
echo "Syntax : $0 number"
echo "Use to print multiplication table for given number"
exit 1
fi
n=$1
for i in 1 2 3 4 5 6 7 8 9 10
do
echo "$n * $i = `expr $i \* $n`"
done
謝謝
可能重複[什麼是特殊的美元符號外殼變量?](http://stackoverflow.com/questions/5163144/what-are-the-special-dollar-sign-shell-variables) – kojiro