【发布时间】:2016-04-21 17:50:07
【问题描述】:
我有 RHEL,我希望运行一个 shell 脚本,它会在 /etc/hosts 文件中添加几行(超过 10 行)。 我尝试使用
sed -i "10.161.61.111 acr111" /etc/hosts
sed -i "10.161.61.110 acr110" /etc/hosts
等等,但我明白了
sed:-e 表达式#1,字符 3:未知命令:`.'
知道如何解决这个问题吗? 或者可能是另一种运行 sh 文件的方式,它将主机添加到主机文件中? 谢谢,
【问题讨论】:
-
额外数据从何而来?文件?多变的?脚本中的数据?
-
@Maya,您可以使用
sed -i和$ a选项向/etc/hosts 添加新条目,请参阅stackoverflow.com/a/50003244/658497