【问题标题】:Meaning of Exclamation mark in Bash command lineBash命令行中感叹号的含义
【发布时间】:2017-06-11 08:56:39
【问题描述】:

我在网上找到了这个命令,查找并显示文件的硬链接,例如文本.txt。

我的问题:这个命令中的感叹号(!)是做什么的?

find $PWD ! -type d -links +1 -ls | sort -n|cut -d" " -f29 | grep --color=auto "$2"

【问题讨论】:

标签: bash shell command-line command-line-arguments


【解决方案1】:

这否定了下一个条件。所以! -type d 表示“不是目录”。

不过有一个问题:! 也是一个特殊字符,用于使 bash 进行历史扩展。这就是为什么你经常不得不逃避 (... \! ...) 或引用它 (... "!" ...)。

另请参阅:find 的手册(尝试man findinfo find)。

【讨论】:

  • 我只是在阅读BashPitfalls,似乎实际上需要单引号......(尤其是在 Bash 4.3 之前)(\!可能工作......)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-07-07
  • 2012-11-01
  • 2017-07-26
相关资源
最近更新 更多