shell get parameters

1. Environment variables can be directly referenced

#!/bin/bash

echo $PATH

2. You can use $n to refer to the parameters entered by the user (when n>=10, use {} to enclose, such as: ${n})

#!/bin/bash
echo $1
echo ${10}

3. You can use read to request user input

#!/bin/bash
read name

#可以使用-p参数给用户提示
read -p'请输入你的名字:' name

Guess you like

Origin blog.csdn.net/qq_53368181/article/details/130062478