为什么 sed 命令包含 at 符号 [英] Why does sed command contain at symbols

查看:55
本文介绍了为什么 sed 命令包含 at 符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白为什么以下 sed 命令包含 @ 符号:

I don't understand why the following sed command contains an @ symbol:

sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd

我查看了/etc/pam.d/sshd 以了解此命令的前后效果:

I've looked at /etc/pam.d/sshd for the before/after effects of this command:

之前:

...
# Set the loginuid process attribute.
session    required     pam_loginuid.so
...

之后:

...
# Set the loginuid process attribute.
session optional pam_loginuid.so
....

@ 符号可能是正则表达式或 sed 语法的一部分吗?找不到关于此的任何文档.

Is the @ symbol possibly part of regex or sed syntax? Could not find any doco on this.

注意:上面的 sed 命令实际上是教程中 Dockerfile RUN 命令的一部分:https://docs.docker.com/examples/running_ssh_service/

Note: The above sed command is actually part of a Dockerfile RUN command in tutorial: https://docs.docker.com/examples/running_ssh_service/

推荐答案

这些是正则表达式和替换字符串的备用分隔符.当您的正则表达式或替换字符串包含/"时非常方便.

These are alternate delimiters for the regular expressions and replacement string. Handy when your regex or replacement string includes '/'.

这篇关于为什么 sed 命令包含 at 符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆