html tool

2024年4月11日星期四

转:shell字符串为空

参考:https://www.cnblogs.com/chuanzhang053/p/8532248.html
#!/bin/bash

str_1=''
str_2=Badboy
if [[ -z $str_1 ]];
then
    echo str_1 is empty.
else
    echo str_1 is not empty.
fi

if [[ -z v$str_2 ]];
then
    echo str_2 is empty.
else
    echo str_2 is not empty.
fi

没有评论:

发表评论