gpt4 book ai didi

mysql - 我无法调试 shell 脚本中的简单错误

转载 作者:太空宇宙 更新时间:2023-11-04 05:04:33 25 4
gpt4 key购买 nike

我正在学习 shell 脚本..

这个效果很好

#!/bin/bash
temp = "test"
if["$temp" = "test"]; then
echo "true"
else
echo "false"
fi

但这不起作用

#!/bin/bash 
while (true) ; do
test=$(exec /usr/bin/mysql -u root -p"password" databasename -N -s -e "select seq from table limit 1 ")
echo $test;
if[ "$test" = "" ]; then
exec ./do_Something.sh $test
else
echo "."
fi
sleep 30
done

错误信息

./tes.sh: line 5: syntax error near unexpected token `then' 
./test.sh: line 5: ` if[ "$test" = "" ]; then'

出了什么问题?

最佳答案

if[之间留一个空格。

关于mysql - 我无法调试 shell 脚本中的简单错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20487597/

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