![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
shell脚本
Makefilehoon
萌妹子初学者,请各位多多指点!
展开
-
shell脚本密码输入
原理比较简单,我就直接发代码了,看不懂的可以私信我! #!/bin/bashecho -n "Enter your name:"read nameecho "hello $name,welcom to my world!"read -s -p"Enter your password:" passecho"log in sucessful!\n"echo原创 2017-12-23 18:00:31 · 1160 阅读 · 0 评论 -
shell脚本if else语句
实例:#!/bin/bashage=30if [ $age -ge 18 ]then echo '已经成年!'else echo '未成年!'fi结果:farsight@ubuntu:~/shell$ vi if.shfarsight@ubuntu:~/shell$ chmod 777 if.shfarsight@ubuntu:~/shell$ ./if.sh已经成年!1 #!/b...原创 2018-06-12 00:16:25 · 3486 阅读 · 0 评论 -
Shell变量的种类
用户自己定义的变量: 由用户自己定义,修改和使用。预定义变量:Bash预定义的特殊变量,不能直接修改。位置变量:通过命令给程序传递执行参数,例如,$n()位置变量有9个,$0 1 2 3 4 5 6 7 8 9#!/bin/bashecho $1echo $2echo $3echo $4echo $5echo $6echo $7echo $7echo $8echo $9echo $10farsig...原创 2018-06-08 00:37:35 · 333 阅读 · 0 评论 -
shell的switch case esac
#!/bin/bash 2 3 case $1 in //输入的第一个参数是否为start 4 start) 5 echo ' start..... ' 6 ;; 7 8 stop) //输入的第一个参数是否为stop 9 echo ' stop... ' 10 ;; 11 esac~ ...原创 2018-06-08 00:39:08 · 4781 阅读 · 0 评论 -
$运算符
$# :命令行中位置参数的个数,$*:打印所有位置参数的内容。$?:上一条命令执行后返回的状态,当返回状态值为0时表示执行正常,非0值表示执行异常或出错。$0:当前执行进程名或者程序名。代码举例:#!/bin/bash 2 3 l111l //此命令执行成功,$?返回0,执行失败,$?返回非0 4 if [[ $? == 0 ]]; then 5 echo '...原创 2018-06-08 00:39:39 · 1368 阅读 · 0 评论 -
shell脚本之循环
shell中的循环分为 while和for1.while语句:格式: while 循环条件 do 循环体 done 结束标志原创 2018-07-10 08:46:38 · 368 阅读 · 0 评论