[: xxxx: Unexpected operator

/***************************************************************************
 *                      [: xxxx: Unexpected operator
 * 说明:
 *     在修改shell脚本的时候遇到这个问题,记录一下解决方法。
 *
 *                                      2017-2-7 深圳 南山平山村 曾剑锋
 **************************************************************************/

一、参考文档:
    1. [ :Unexpected operator in shell programming [duplicate]
        http://stackoverflow.com/questions/3411048/unexpected-operator-in-shell-programming

二、解决办法:
    1. 原因:There is no mistake in your bash script. But you are executing it with sh which has a less extensive syntax。
    2. 将shell脚本第一行#!/bin/sh换成#!/bin/bash

 

posted on 2017-02-07 17:15  zengjf  阅读(2314)  评论(0编辑  收藏  举报

导航