[英]\! In Bash Commands
What is the function of \\!
\\!
的功能是什么\\!
in a bash command? 在bash命令中?
For example, I notice that this command below will differ in behavior with \\!
例如,我注意到下面的命令与\\!
行为会有所不同\\!
: :
find subdir -lname 'test*' \\! -newer somethinghere
Google searching does not appear to bring up anything specifically related to \\!
Google搜索似乎未显示与\\!
相关的任何内容\\!
except for command line formatting. 命令行格式除外。
Putting a backslash before a character escapes it, preventing it from being parsed as syntax. 将反斜杠放在字符转义符之前,以防止将其解析为语法。 Thus, \\!
因此, \\!
is a terser equivalent to '!'
是相当于'!'
的简短形式 -- it ensures that find
is passed !
-确保find
通过!
as an argument, without the shell interpreting it in any way. 作为参数,而无需外壳以任何方式解释它。
Without either of these, if [[ $- = *H* ]]
(which is true in an interactive shell and by default), and if histchars
is unmodified from its default value, !
如果没有上述任何一个,则为[[ $- = *H* ]]
(在交互式shell中为默认值,并且默认情况下为true),并且histchars
的默认值未更改!
triggers history expansion. 触发历史扩展。 This is per the bash man page's QUOTING section: 这是根据bash手册页的QUOTING部分:
When the command history expansion facilities are being used (see HISTORY EXPANSION below), the history expansion character, usually
!
当使用命令历史记录扩展工具时(请参见下面的HISTORY EXPANSION),历史记录扩展字符通常是!
, must be quoted to prevent history expansion. 必须加引号,以防止历史记录扩展。
The ! ! is for negation , for instance: 用于否定 ,例如:
find . -readable
will return all readable files/directories, whereas 将返回所有可读文件/目录,而
find . ! -readable
will return all files/directories that can not be read (broken link or -r permission) 将返回所有无法读取的文件/目录(链接断开或-r权限)
The \\ char is for escaping. \\ char用于转义。
However, curiously on my computer (Debian/bash) I need to escape the * char but not the ! 但是,奇怪的是,在我的计算机(Debian / bash)上,我需要转义* char而不是!! one. 一。 To be more explicit I need to write 更明确地说,我需要写
find . -name abc\*
but 但
find . -name abc\* ! -readable
find . -name abc\* \! -readable
work and have same effect 工作并具有相同的效果
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.