【问题标题】:Shell scripting not giving actual response [duplicate]Shell脚本没有给出实际响应[重复]
【发布时间】:2018-09-08 18:33:43
【问题描述】:
#!/bin/sh
read name
if test "$name"=akash
then 
echo "Hello how are you"
else
echo "sorry"

这是我的脚本,但在这两种情况下,我都会收到“你好,你好吗”的回复

【问题讨论】:

标签: linux shell if-statement scripting


【解决方案1】:

您正在测试单个字符串 "$name"=akash 是否为空。 = 周围需要空格,以便 test 看到三个单独的参数。

if test "$name" = akash
then

【讨论】:

  • 谢谢兄弟。这解决了我的问题。
猜你喜欢
  • 2016-03-22
  • 1970-01-01
  • 2015-05-14
  • 1970-01-01
  • 2019-08-23
  • 2016-01-03
  • 2015-09-01
  • 2014-07-23
相关资源
最近更新 更多