每天写点shell
Posted 子非木
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了每天写点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的主要内容,如果未能解决你的问题,请参考以下文章