嗨,我是bash脚本的新手.刚刚编写了这个简单的程序,但它正在抛出错误.
- #!/bin/bash
- os=`uname -o`
- echo $os
- if ["$os"=="GNU/Linux"] ; then
- echo "Linux"
- else
- echo "Windows"
- fi
使用==或-eq两种情况我得到以下错误,它正在打印else condn.
./ostype.sh:line 3:[GNU / Linux == GNU / Linux]:没有这样的文件或目录
视窗
Bash版本:GNU bash,版本3.2.48(1)-release(x86_64-suse-linux-gnu)
尝试
- if [ "$os" = "GNU/Linux" ]
注意空格,单=.
[实际上是一个程序,其余的都是参数!