shell字符串截取报错 Bad substitution 的解决方法
问题:
脚本执行到截取字符串时,报错提示:Bad substitution。
原因:
两种shell语言解释器 bash和dash,这种情况是指向了dash解释器导致。
解决方法:
1.查看shell指向:ls -l /bin/sh
2.修改脚本指向bash方法1:sudo dpkg-reconfigure dash 然后选择 no
修改脚本指向bash方法2:sudo rm -rf /bin/sh
sudo ln -s /bin/bash /bin/sh
本文来自博客园,作者:白菜没我白,转载请注明原文链接:https://www.cnblogs.com/xingboy/p/16898309.html