我需要在sed命令行中引用什么? [英] What do I need to quote in sed command lines?

查看:45
本文介绍了我需要在sed命令行中引用什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此网站上有许多有关如何逃避sed的各种问题的问题,但我正在寻找更一般的答案.我知道我可能想转义一些字符以避免shell扩展:

There are many questions on this site on how to escape various elements for sed, but I'm looking for a more general answer. I understand that I might want to escape some characters to avoid shell expansion:

Bash :

  • 单引号[strings] ('')用于保留引号内每个字符的字面值.[但是,]即使在单引号前加上反斜杠,也可能不会出现 单引号 .
  • 仅当后跟美元反引号双引号时,反斜杠才保留其含义[在双引号字符串中]strong>,反斜杠换行符.在双引号中,当反斜杠后面是这些字符之一时,将从输入流中删除.没有特殊含义的反斜杠前面的字符将保留不变,以供shell解释器处理.
  • Single quoted [strings] ('') are used to preserve the literal value of each character enclosed within the quotes. [However,] a single quote may not occur between single quotes, even when preceded by a backslash.
  • The backslash retains its meaning [in double quoted strings] only when followed by dollar, backtick, double quote, backslash or newline. Within double quotes, the backslashes are removed from the input stream when followed by one of these characters. Backslashes preceding characters that don't have a special meaning are left unmodified for processing by the shell interpreter.

sh :(我希望您没有历史扩展)

sh: (I hope you don't have history expansion)

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