Sheel 脚本接收键盘输入

一、通过read 接收

1. 通过vim 定义一个test.sh的脚本

vim test.sh

2. 编写shell脚本

#! /bin/bash
read name
echo "$name It is a test"

3. 添加脚本执行权限

chmod +x test.sh 

4. 执行脚本

[root@test-29 ~]# ./test.sh 
OK
OK It is a test

 

posted @ 2021-02-16 08:47  呆人  阅读(96)  评论(0)    收藏  举报