Bad substitution

1 错误描述

    执行如下字符串替换时,提示错:Bad substitution。

${string/sub/replace}
2 解决方法    

    上述替换语句是bash shell的语法,而在指定shell脚本的解析器为/bin/sh,它默认链接到dash shell,因此需要在shell脚本中明确的指出使用bash shell:

#!/bin/bash

参考资料

[1]终端出现syntax error: bad substitution是什么问题

你可能感兴趣的:(Bad substitution)