【发布时间】:2016-04-20 21:58:16
【问题描述】:
我想在 Linux 中执行一个 sed 命令来取消注释“#auth”
原始文件
#%PAM-1.0
auth sufficient pam_rootok.so
# Uncomment the following line to implicitly trust users in the "wheel" group.
#auth sufficient pam_wheel.so trust use_uid
我可以写这个命令来做到这一点:
sed 's/#auth.*sufficient.*pam_wheel.so trust use_uid/auth\t sufficient\t pam_wheel.so trust use_uid/' /etc/pam.d/su
但我认为它太长了。有没有更好的方法来做到这一点(更通用)? 我不想指定行号来替换它,因为如果有人更改了文件,脚本将无法正常运行。
例如:
搜索关键字“#auth.*sufficient.*pam_wheel.so trust use_uid”,如果找到,将这个词“#auth”替换为“ auth",然后在该行中附加后面的措辞
【问题讨论】: