1.什么是交互式变量?
当我们在shell中输入一条命令回车的时候,会让填写一些内容才会继续往下走
也就是传统的一问一答的模式
比如passwd命令
2.编写脚本实现交互式的操作
vim test1.sh
#!/bin/bash
read -p "ni chou sha: " TARGET使用read命令实现交互式
echo "$TARGET"
sh test1.sh
vim test2.sh
#!/bin/bash
read -p "please input ipaddress: " TARGET
ping -c1 -w1 $TARGET &> /dev/null && {
echo $TARGET is up
} || {
echo $TARGET is down
}