我希望在我的bash脚本中运行一个命令,根据环境变量$VERBOSE是否定义来选择是否加上
```bash if [ -n "$VERBOSE" ]; then mycommand -v else mycommand fi ```
-v
标志。就像这样:```bash if [ -n "$VERBOSE" ]; then mycommand -v else mycommand fi ```
#!/bin/bash
/usr/local/bin/mongo-connector \
-m $MONGO_HOST \
-t $NEO_URI \
[if $VERBOSE then -v ] \
-stdout
case
语句。没有简单的捷径。 - William Pursell