我有以下脚本:
echo 'Please select type file , the name of the input file and the name of the output file:
a.plain ( please press a ) <input_file> <output_file>;
b.complex ( please press b ) <input_file> <output_file>;'
read one two three
echo $#
if [ $# -ne 3 ]; then
echo "Insufficient arguments !"
exit 1;
else
echo "Number of passed parameters is ok"
fi
Run Code Online (Sandbox Code Playgroud)
$# 始终输出 0 ,当我稍后在脚本中使用 $one 、 $two 和 $three 时, read 命令会提供正确的变量
谢谢你。