linux-tutorial/codes/shell/示例脚本/输入和输出/读取参数.sh

11 lines
186 B
Bash

#!/bin/bash
# using one command line parameter
factorial=1
for (( number = 1; number <= $1; number++))
do
factorial=$[ $factorial * $number ]
done
echo The factor of $1 is $factorial