[: xxxx: Unexpected operator

简介: /*************************************************************************** * [: xxxx: Unexpected operator * 说明: * 在修改shell脚本的时候遇到这个问题,记录一下解决方法。
/***************************************************************************
 *                      [: 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

 

目录
相关文章
|
4月前
|
iOS开发
解决Invalid `Podfile` file: no implicit conversion of nil into String
解决Invalid `Podfile` file: no implicit conversion of nil into String
45 0
|
7月前
【报错】 “TypeError: Cannot read properties of undefined (reading ‘split‘)“
【报错】 “TypeError: Cannot read properties of undefined (reading ‘split‘)“
938 0
|
7月前
|
Python
完美解决丨File “invalid.py“, line 1 print(`Hello World!`) ^ SyntaxError: invalid syntax
完美解决丨File “invalid.py“, line 1 print(`Hello World!`) ^ SyntaxError: invalid syntax
error C2041: illegal digit ‘9‘ for base ‘8‘ | error C2059: syntax error: ‘bad suffix on number‘
error C2041: illegal digit ‘9‘ for base ‘8‘ | error C2059: syntax error: ‘bad suffix on number‘
145 0
成功解决absl.flags._exceptions.UnrecognizedFlagError: Unknown command line flag 'data_format'
成功解决absl.flags._exceptions.UnrecognizedFlagError: Unknown command line flag 'data_format'
报错 ValueError: too many values to unpack (expected 2)
报错 ValueError: too many values to unpack (expected 2)
215 0
|
Shell
编译OpenJDK8-u332:/bin/sh: 1: [: -a: unexpected operator/line 0: [: too many arguments
编译OpenJDK8-u332:/bin/sh: 1: [: -a: unexpected operator/line 0: [: too many arguments
178 0
error: passing ‘const AppJniCommand’ as ‘this’ argument discards qualifiers [-fpermissive]
error: passing ‘const AppJniCommand’ as ‘this’ argument discards qualifiers [-fpermissive]
103 0
|
C语言
error: implicit declaration of function ‘VerifyFixClassname‘ is invalid in C99 [-Werror,-Wimplicit-f
error: implicit declaration of function ‘VerifyFixClassname‘ is invalid in C99 [-Werror,-Wimplicit-f
150 0
解决办法: error: passing ‘const VideoFrame’ as ‘this’ argument discards qualifiers [-fpermissive]
解决办法: error: passing ‘const VideoFrame’ as ‘this’ argument discards qualifiers [-fpermissive]
237 0