![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Shell
w-serendipity
这个作者很懒,什么都没留下…
展开
-
Shell中将Linux语句的值赋给变量
在Shell脚本中想要将Linux语句执行的结果赋值给某个变量,一定要将语句用反引号(Esc键下面的键)包裹起来,用单引号、双引号或者不用引号,该变量都得不到该语句执行的结果如下,#!/bin/bashstring=`cat test.txt |grep ms`echo "根据正则匹配到的文本:${string}"其中test…txt内容如下Just have patience,Your dreams will come true.最终结果如下Your dreams will co原创 2021-12-22 18:13:06 · 1272 阅读 · 0 评论 -
Shell脚本报错./test3.sh: line 3: [: missing `]‘
在运行下面Shell脚本的时候报错./test3.sh: line 3: [: missing `]'./test3.sh: line 10: [: missing `]'这是脚本代码#!/bin/bashif [ true && true ]then echo trueelse echo falsefiif [ true || true ]then echo trueelse echo fals原创 2021-12-10 16:28:55 · 1269 阅读 · 0 评论