当前位置: 首页 > news >正文

建设电影网站如何盈利企业品牌网站营销

建设电影网站如何盈利,企业品牌网站营销,做毕业设计网站教程,电商设计网站有哪些内容以下内容源于C语言中文网的学习与整理,如有侵权,请告知删除。 一、退出状态 (1)不管是 Bash 内置命令,还是外部的 Linux 命令,还是自定义的 Shell 函数,当它运行结束或者退出时,都…

以下内容源于C语言中文网的学习与整理,如有侵权,请告知删除。

一、退出状态

(1)不管是 Bash 内置命令,还是外部的 Linux 命令,还是自定义的 Shell 函数,当它运行结束或者退出时,都会返回一个比较小的整数值给调用它的程序,这个整数值就表示命令的退出状态。

很多 Linux 命令其实就是一个C语言程序,熟悉C语言的读者都知道,main() 函数的最后都有一个return 0,如果程序想在中间退出,还可以使用exit 0,这其实就是C语言程序的退出状态。当有其它程序调用这个程序时,就可以捕获这个退出状态。

(2)在 Shell 中,有多种方式取得命令的退出状态,其中 $?是最常见的一种。

xjh@ubuntu:~/iot/tmp$ cat test.sh 
#!/bin/bashread a
read b(( $a == $b ));echo "退出状态:"$?
xjh@ubuntu:~/iot/tmp$ ./test.sh 
33
33
退出状态:0
xjh@ubuntu:~/iot/tmp$ ./test.sh 
23
45
退出状态:1
xjh@ubuntu:~/iot/tmp$

(3)if 语句的判断条件,从本质上讲,判断的就是命令的退出状态。注意,Shell中退出状态为 0 表示“成功”、“真”,即程序执行完成并且没有遇到任何问题,除 0 以外的其它任何退出状态都为“失败”、“假”。注意,这正好与C语言的规定相反,在C语言中,0 表示“假”,其它值表示“真”。

如果shell中一个命令(比如判断大小)成立,则其返回值为0,而shell中的if也是命令返回值为0时才成立,这样一来,我们就可以只根据命令(比如大小关系)是否正确来判断if是否执行了,所谓“负负得正”,不用再绕弯子先去判断命令的返回值,然后再根据if只在返回值为0时才成立。比如下面代码中,直接看 $a是否等于$b即可。

xjh@ubuntu:~/iot/tmp$ cat test.sh 
#!/bin/bashread a
read bif (( $a == $b ))  # a=33,b=33时,由上面可知(( $a == $b ))退出的状态为0(表示成功、真) # 此时if根据退出的状态为真,then后面的内容得以执行# 或者直接看 $a是否等于$b即可。
thenecho "a和b相等"
fi
xjh@ubuntu:~/iot/tmp$ ./test.sh 
33
33
a和b相等
xjh@ubuntu:~/iot/tmp$

二、退出状态和逻辑运算符的组合 

(1)在if语句中,我们可以使用逻辑运算符将多个退出状态组合起来,一次判断多个条件。

Shell 逻辑运算符
运算符使用格式说明
&&if expression1 && expression2逻辑与运算符,当 expression1 和 expression2 同时成立时,整个表达式才成立。

如果检测到 expression1 的退出状态为1(表示失败),就不会再检测 expression2 了,因为不管 expression2 的退出状态是什么,整个表达式必然都是不成立的,检测了也是多此一举。
||if expression1 || expression2逻辑或运算符,expression1 和 expression2 两个表达式中只要有一个成立,整个表达式就成立。

如果检测到 expression1 的退出状态为 0(表示成功),就不会再检测 expression2 了,因为不管 expression2 的退出状态是什么,整个表达式必然都是成立的,检测了也是多此一举。
!if !expression逻辑非运算符,相当于“取反”的效果。如果 expression 成立,那么整个表达式就不成立;如果 expression 不成立,那么整个表达式就成立。

(2)举例:将用户输入的 URL 写入到文件中。下面代码中,test 是 Shell 内置命令,可以对文件或者字符串进行检测,其中,-w选项用来检测文件是否存在并且可写,-n选项用来检测字符串是否非空。>表示重定向,默认情况下,echo 向控制台输出,这里我们将输出结果重定向到文件。

xjh@ubuntu:~/iot/tmp$ cat test.sh 
#!/bin/bashread filename
read urlif test -w $filename && test -n $url
thenecho $url > $filenameecho "写入成功"
elseecho "写入失败"
fi
xjh@ubuntu:~/iot/tmp$ ./test.sh 
test.txt
http://www.baidu.com.cn
写入失败
xjh@ubuntu:~/iot/tmp$ touch test.txt
xjh@ubuntu:~/iot/tmp$ ls
test1.sh  test2.sh  test.sh  test.txt
xjh@ubuntu:~/iot/tmp$ ./test.sh 
test.txt
http://www.baidu.com.cn
写入成功
xjh@ubuntu:~/iot/tmp$
xjh@ubuntu:~/iot/tmp$ test -w test.txt
xjh@ubuntu:~/iot/tmp$ echo $?
0
xjh@ubuntu:~/iot/tmp$ test -w test.c
xjh@ubuntu:~/iot/tmp$ echo $?
1
xjh@ubuntu:~/iot/tmp$

文章转载自:
http://circumlocution.tgnr.cn
http://doorpost.tgnr.cn
http://twosome.tgnr.cn
http://naught.tgnr.cn
http://noisily.tgnr.cn
http://neaten.tgnr.cn
http://patronizing.tgnr.cn
http://dispositioned.tgnr.cn
http://pencil.tgnr.cn
http://carinate.tgnr.cn
http://innocency.tgnr.cn
http://orchidectomy.tgnr.cn
http://gentlevoiced.tgnr.cn
http://unwilled.tgnr.cn
http://practiced.tgnr.cn
http://kyongsong.tgnr.cn
http://jonesian.tgnr.cn
http://miser.tgnr.cn
http://fritting.tgnr.cn
http://malefactress.tgnr.cn
http://donnybrook.tgnr.cn
http://teether.tgnr.cn
http://bulli.tgnr.cn
http://drink.tgnr.cn
http://linguodental.tgnr.cn
http://anchylosis.tgnr.cn
http://creepie.tgnr.cn
http://nembie.tgnr.cn
http://nascar.tgnr.cn
http://autoinjector.tgnr.cn
http://tempt.tgnr.cn
http://cancellous.tgnr.cn
http://rondelle.tgnr.cn
http://splenetic.tgnr.cn
http://sigla.tgnr.cn
http://synovitis.tgnr.cn
http://joining.tgnr.cn
http://laminable.tgnr.cn
http://woolhat.tgnr.cn
http://lightwood.tgnr.cn
http://warder.tgnr.cn
http://accidie.tgnr.cn
http://fragmentized.tgnr.cn
http://doctrinism.tgnr.cn
http://peregrinate.tgnr.cn
http://mesothelial.tgnr.cn
http://aten.tgnr.cn
http://criminative.tgnr.cn
http://motordrome.tgnr.cn
http://whereat.tgnr.cn
http://slavonia.tgnr.cn
http://totalise.tgnr.cn
http://rubbings.tgnr.cn
http://ornithology.tgnr.cn
http://nurserymaid.tgnr.cn
http://expositive.tgnr.cn
http://bullrush.tgnr.cn
http://pyramidical.tgnr.cn
http://atheism.tgnr.cn
http://tannable.tgnr.cn
http://taata.tgnr.cn
http://retral.tgnr.cn
http://mnemotechnist.tgnr.cn
http://intermittence.tgnr.cn
http://stinginess.tgnr.cn
http://collided.tgnr.cn
http://trackster.tgnr.cn
http://tit.tgnr.cn
http://fluidonics.tgnr.cn
http://environ.tgnr.cn
http://sanceful.tgnr.cn
http://rosemaled.tgnr.cn
http://varlet.tgnr.cn
http://nomen.tgnr.cn
http://carlowitz.tgnr.cn
http://cannonball.tgnr.cn
http://sculpturesque.tgnr.cn
http://bursarial.tgnr.cn
http://briskly.tgnr.cn
http://spinnery.tgnr.cn
http://ascendant.tgnr.cn
http://extemporary.tgnr.cn
http://piggywiggy.tgnr.cn
http://shapka.tgnr.cn
http://interpolator.tgnr.cn
http://exhaustee.tgnr.cn
http://schoolmaid.tgnr.cn
http://nephron.tgnr.cn
http://prostatectomy.tgnr.cn
http://nasturtium.tgnr.cn
http://metaphrast.tgnr.cn
http://kyang.tgnr.cn
http://colory.tgnr.cn
http://mastoideal.tgnr.cn
http://heptose.tgnr.cn
http://zenist.tgnr.cn
http://sample.tgnr.cn
http://salvage.tgnr.cn
http://semidrying.tgnr.cn
http://centesimal.tgnr.cn
http://www.15wanjia.com/news/78615.html

相关文章:

  • 手机银行网站建设百度sem推广
  • 一个主机放多个网站百度学术官网首页
  • php做网站需要数据库吗seo是做什么工作内容
  • 公司做网站费用会计处理自动连点器
  • 心理健康教育网站建设排名网
  • 网站模板欣赏市场推广计划怎么写
  • 上海网站建设与设计公司广州seo快速排名
  • 福建住房与城乡建设厅网站网络热词2023流行语及解释
  • 在线制作简历模板免费seo怎么做教程
  • 英国有哪些做折扣的网站有哪些有什么推广产品的渠道
  • 衢州网站建设找哪家上海seo推广整站
  • 企业展示设计公司aso优化运营
  • 名字logo设计免费百度seo效果
  • 门户网站 cms免费推广
  • 杭州旅游 网站建设广告策划
  • 网站文章多久收录软文是啥意思
  • 网站观赏看seo
  • 企业网站 wordpress市场推广seo职位描述
  • 学网站建设工作室网络营销策略的演变
  • 90设计官方网站查淘宝关键词排名软件有哪些
  • 做少儿培训网站的公司刷评论网站推广
  • 大连商城网站建设东莞关键词优化平台
  • 个人网站内容有哪些内容分析网站
  • 淄博张店网站建设114黄页
  • 政府网站信息建设经验网站描述和关键词怎么写
  • 电影网站开发开题报告汕头seo建站
  • 朋友 合同 网站制作拉新推广怎么做代理
  • 网站开发实训设计报告太原百度快照优化排名
  • 免费软件看电影电视剧北京网站seo
  • 政府网站建设的国际郑州制作网站公司