首页 > 代码库 > 每天写点shell
每天写点shell
1、read基本读取
1 #!/bin/bash 2 #testing the read command 3 4 echo -n "Enter you name:" #echo -n 让用户直接在后面输入 5 read name # 6 echo "Hello $name, welcome to my program."
执行:
# ./read.sh Enter you name: wangtao Hello wangtao, welcome to my program.
2、read -p (直接在read命令行指定提示符)
1 #!/bin/bash 2 #testing the read -p option 3 read -p "Please enter your age: " age 4 days=$[ $age * 365 ] 5 echo "That makes you over $days days old!"
执行:
# ./age.sh Please enter your age: 23 That makes you over 8395 days old!
每天写点shell
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。