linux - shellscript - “$#” [duplicate]
问题 This question already has answers here : What does the $# construct mean in bash? [duplicate] (3 answers) Closed 5 years ago . I have a shellscript with the following lines: set -o nounset set -o errexit set -o xtrace if [ "$#" -ne 0 ] then echo 'A message' exit 1 fi Can somebody explain the commands, in particular the setter and the "$#" portion? 回答1: $# is the number of arguments passed to the script. So this if [ "$#" -ne 0 ] check ensures that if no arguments are passed then the script