我有以下bash脚本:
#!/bin/bash
if [ ! -f numbers ]; then echo 0 > numbers; fi
count = 0
while [[$count != 100]]; do
count = `expr $count + 1`
done
当我在我的Mac上的终端上运行它时,我得到以下输出:
seq_file_gen.sh: line 3: count: command not found
seq_file_gen.sh: line 4: [[: command not found
我为什么要犯这些错误?这个剧本是我老师给我的,所以我不知道为什么这个剧本不能运行。任何帮助都将不胜感激。
编辑:这是编写这个脚本的正确方法(用空格)
#!/bin/bash
if [ ! -f numbers ]; then echo 0 > numbers; fi
count=0
while [[ $count != 100 ]]; do
count=`expr $count + 1`
done
发布于 2015-02-09 20:17:53
在[[
和]]
之后添加空格,如下所示:
while [[ $count != 100 ]]; do
https://stackoverflow.com/questions/28418486
复制相似问题