我尝试在 bash 脚本中进行基本的字符串替换:
#!/bin/bash
x="I love Linux"
echo "${x/Linux/Unix}"
Run Code Online (Sandbox Code Playgroud)
它在我的 Mac 上运行良好,但在我的服务器上不起作用。我尝试了不同网站的不同示例,但总是收到错误:
Bad substitution
我的 bash 版本:GNU bash, Version 4.4.12(1)-release (x86_64-pc-linux-gnu)
我究竟做错了什么?
shell-script ×1