Sheel 脚本接收键盘输入

时间:2021-02-18 13:13:07   收藏:0   阅读:0

一、通过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

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!