【发布时间】:2017-06-02 01:09:33
【问题描述】:
我正在尝试在脚本中修改我的 linux 机器上的某个文件。该文件是 /etc/pam.d/login 文件。问题是文件的内容是,
# Prints the message of the day upon succesful login.
# (Replaces the `MOTD_FILE' option in login.defs)
# This includes a dynamically generated part from /run/motd.dynamic
# and a static (admin-editable) part from /etc/motd.
session optional pam_motd.so motd=/run/motd.dynamic noupdate
session optional pam_motd.so
我需要注释掉这个文件中的第二个会话行,但是当我去字符串匹配时,结果如下(我正在使用 SED 为那些感兴趣的人这样做)。
# Prints the message of the day upon succesful login.
# (Replaces the `MOTD_FILE' option in login.defs)
# This includes a dynamically generated part from /run/motd.dynamic
# and a static (admin-editable) part from /etc/motd.
#session optional pam_motd.so motd=/run/motd.dynamic noupdate
#session optional pam_motd.so
因为第一行也符合条件。我如何确保整行匹配“会话可选 pam_motd.so”,而不仅仅是它的某个部分。
谢谢!
【问题讨论】: