将参数传递给脚本(Shell基础教程3)

Passing Arguments to the Script

BIG=$5 echo "A$BIG costs just $6" --> results with: A Fruit Basket costs just 15  变量$#保留传递给脚本的参数数量

echo $# --> results with: 6 变量$@包含一个以空格分隔的字符串,其中包含传递给脚本的所有参数

Tutorial Code

#!/bin/bash
# There is no exercise for this section.
# You may proceed.


Solution

#!/bin/bash
# There is no exercise for this section.
# You may proceed.


Expected Output

#!/bin/bash
# There is no exercise for this section.
# You may proceed.