Linux shell 编程基础

Linux shell 编程基础

https://blog.csdn.net/xiaoxiaowenqiang/article/details/138919126?spm=1001.2014.3001.5502
https://blog.csdn.net/zhanghm1995/article/details/106015625

  1. 将命令输出存储到变量中的语法是
diff_result=$(diff stc_compile_multifile_withso_build.log stc_compile_multifile_build.txt | wc -l)
keyword_num=$(grep -o 'OFFLOAD' stcc_out_result0.txt| wc -l)
  1. 条件判断
keyword_num=$(($keyword_num1+$keyword_num2))
if [ $diff_result == 0 ] && [ $keyword_num == 3 ]
then
	echo "stc_compile_multifile_withso_build result Passed."
	rm -rf stc_compile_multifile_withso_build.log
else
	echo "stc_compile_multifile_withso_build result Failed."
	mv stc_compile_multifile_withso_

使用set更改shell特性时,符号+和-的作用分别是关闭和打开指定的模式
image

  1. 使用 set/env/export 的区别
    image

  2. Shell脚本中的:=是什么意思

:= 意思就是
如果这个变量是空的或者未赋初值,则对其进行赋值. 否则, 就不赋值.

https://zhuanlan.zhihu.com/p/264346586
https://blog.csdn.net/x1269778817/article/details/46535729
https://www.cnblogs.com/xuxm2007/archive/2011/10/20/2218846.html
https://handerfly.github.io/shell/2019/04/03/shell编程冒号加-等号-加号-减号-问号/

https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Shell-Builtin-Commands
https://www.cnblogs.com/itcomputer/p/5035387.html
https://chegva.com/3818.html
https://gist.github.com/maxisam/e39efe89455d26b75999418bf60cf56c#file-bash_strict_mode-md

https://www.cnblogs.com/wjoyxt/category/577808.html
https://www.cnblogs.com/wjoyxt/category/577808.html
http://home.ustc.edu.cn/~xie1993/linux/linux-shell-func.html

https://www.cnblogs.com/everest33Tong/p/14559201.html

posted @ 2021-05-21 17:51  michaelchengjl  阅读(48)  评论(0)    收藏  举报