gpt4 book ai didi

linux - if 语句在 Bash 脚本中不起作用

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:56:06 25 4
gpt4 key购买 nike

<分区>

我不明白为什么这个用于检查字符串是否为空的简单 if 语句不起作用。它给了我:

syntax error near unexpected token `then'

#!/bin/bash
str="Hello World!"
if[ ! -z "$str"]; then
echo "str is not empty"
fi

我在我的 PC 上试过了,一个 online editor也一样,但它显示了同样的问题。有什么想法吗?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com