echo 在 bash 脚本中更改“--md5”到“?-md5”
我正在编写一个 VMWare ESX 自动构建脚本,但我遇到了最后一个障碍,可能是因为我真的不擅长编写脚本。
我需要保护 Grub,所以在我的脚本中我有类似的说法;
echo "password --md5 password-converted-to-md5" >> /boot/grub/grub.conf
不幸的是,这会将以下内容放入该文件中;
password ?-md5 password-converted-to-md5
我知道这对你们中的一些人来说很简单,但我已经在谷歌上搜索了几个小时,我感到很沮丧。
预先非常感谢您。
I'm writing a VMWare ESX automated build script and I'm falling at the last hurdle, probably as I'm really not strong at scripting.
I need to secure Grub so in my script I have a like saying;
echo "password --md5 password-converted-to-md5" >> /boot/grub/grub.conf
This unfortunately places the following into this file;
password ?-md5 password-converted-to-md5
I know it's a simple one for some of you guys but I've been googling for hours and I'm getting frustrated.
Thank you very much in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
确保你有简单的ascii破折号,而不是其他字符,如不间断连字符、数学减号、短破折号、长破折号等。最好是重新输入你的行,这有望解决你的问题
make sure you have simple ascii dashes and not other chars like non-breaking-hyphen, mathematical-minus, en-dash, em-dash, etc. best is to just re-type your line, this will hopefully solve your problem
我会使用简单的引用,看看它是否有帮助:
或使用变量:
I would use simple quote and see if it's help:
or with a variable: