linux教程:shell脚本基本语法

2024-10-25 15:45:36

1、if判断语句的写法是这样:#!/bin/basha=1;if [ $a -lt 10 ]; then echo "ok"fi其中a=1中间一定不能有空格,如果a<10打印ok。

linux教程:shell脚本基本语法

3、字符串相等:#!/bin/basha="hello"if [ $a = "hello" ]; then echo "ok"fi

linux教程:shell脚本基本语法

5、另一种字符串比较方法:#!/bin/basha屏顿幂垂="hello"if [[ $a == *"he造婷用痃llo"* ]]; then echo "match ok"else echo "match fail"fi

linux教程:shell脚本基本语法
猜你喜欢