shell script学习

来源:互联网 发布:郑州网络诈骗最新新闻 编辑:程序博客网 时间:2024/05/21 07:58

1、第一个hello world

#!/bin/bashecho 'hello world'
#!/bin/bash:代表的是使用的是哪一种shell


2、变量内容由使用者决定(使用定义过的变量用在变量名前加$)

#!/bin/bashread -p "please input your firstname:" firstnameread -p "please input your lastname:" lastnameecho "\n Your full is: $firstname $lastname"


3、数字运算

#!/bin/bashread -p "first number: " firstnumread -p "second number: " secondnumtotal=$(($firstnum*$secondnum))echo "The result of $firstnum * $secondnum is $total"
运算方式:$((运算内容))




原创粉丝点击