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

posted @   michaelchengjl  阅读(43)  评论(0编辑  收藏  举报
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
点击右上角即可分享
微信分享提示