我有这个设置在SSH吐露(/etc/ssh/sshd_config)
AllowUsers root john我想将jane添加到行尾
AllowUsers root john jane 我试过了
sed -i -e '/AllowUsers/{s/:/ /g;s/.*=//;s/$/ jane/p}' /etc/ssh/sshd_config && cat /etc/ssh/sshd_config我一直得到这个结果
AllowUsers root john jane
AllowUsers root john jane 为什么会有额外的排队?
备注
如果我以某种方式运行该命令两次
我会得到这些结果的
AllowUsers root john jane
AllowUsers root john jane
AllowUsers root john jane
AllowUsers root john jane 再运行一次x3次数,会给我这个
AllowUsers root john jane
AllowUsers root john jane
AllowUsers root john jane
AllowUsers root john jane
AllowUsers root john jane
AllowUsers root john jane
AllowUsers root john jane
AllowUsers root john jane
AllowUsers root john jane
AllowUsers root john jane 发布于 2020-08-26 21:25:38
p标志在s/$/ jane/p中将打印模式空间。然后,当周期结束时,将再次打印模式空间,从而产生两行。移除p标志。
尽管如此,只是:
sed 's/AllowUsers .*/& jane/'https://stackoverflow.com/questions/63605689
复制相似问题