首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

简单的shell脚本运行抱错,请帮忙看下解决办法

2012-03-01 
简单的shell脚本运行抱错,请帮忙看下#!/bin/sh#this is testif[1 0]thenecho out 1fi./test123运

简单的shell脚本运行抱错,请帮忙看下
#!/bin/sh
#this is test
if["1" > "0"]
then
  echo "out 1"
fi



./test123运行提示 if[1:command not found

[解决办法]
加空格
[解决办法]
[前后要加空格
在linuxshell里,空格很重要

[解决办法]
#!/bin/sh
#this is test
if [ "1" > "0" ] #加空格
then
echo "out 1"
fi

# chmod +x test.sh
# ./test.sh
out 1
[解决办法]
if语句里 [ "1" > "0" ] 两边都需要空格的
[解决办法]
if[ "1" > "0" ]
then
echo "out 1"
fi

热点排行