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