好久没写linux脚本了,连最基础的东西都忘记了。
回头复习了一下,随便写了个程序就报错。
之前所在公司无法联网,所以没有记blog的习惯。现在不在那种保密级单位了,还是要多写写linux技术博客。
以下是原来有错误的脚本原文:
#!/bin/bash
#by authors test
dir=/root/test/test01
if[ ! -d $dir ];then
echo -e "$dir not exits!"
mkdir -p $dir
else
echo -e "$dir is already exists!"
fi
一运行,竟然提示 syntax error near unexpected token `then'
细查之下,发现是if和中括号之间也要加空格,这一点倒是忘记了。
加上空格,一切搞定。
转载于:https://blog.51cto.com/linux200801/1670868