gpt4 book ai didi

string - 在 Bash 中比较两个字符串时出现 "command not found"错误

转载 作者:行者123 更新时间:2023-11-29 08:40:46 24 4
gpt4 key购买 nike

目前我的整个脚本是这样的:

#!/bin/sh   
clear;
blanko="";
# Dummy-Variablen
variable=Testvariable;
if [[$variable == $blanko]];
then
echo "Nichts da!"
else
echo $variable
fi

如果我输入

TestSelect.sh

我明白了

/usr/bin/TestSelect.sh: line 6: [[Testvariable: command not found   
Testvariable

我该如何解决这个问题?

最佳答案

这是个问题:

if [[$variable == $blanko]];

方括号内需要空格,这样使用:

[[ "$variable" == "$blanko" ]] && echo "Nichts da!" || echo "$variable"

关于string - 在 Bash 中比较两个字符串时出现 "command not found"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19733437/

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