"-ne"是什么意思?卑鄙的意思? [英] What does "-ne" mean in bash?
问题描述
bash脚本中的命令"-ne"是什么意思?
What does the command "-ne" mean in a bash script?
例如,bash脚本的以下行是做什么的?
For instance, what does the following line from a bash script do?
[ $RESULT -ne 0 ]
推荐答案
如果您不知道在哪里看,这是很难搜索的东西之一.
This is one of those things that can be difficult to search for if you don't already know where to look.
[
实际上是一个命令,不是您可能期望的bash shell语法的一部分.它恰好是Bash内置命令,因此已在Bash手册中进行了记录.
[
is actually a command, not part of the bash shell syntax as you might expect. It happens to be a Bash built-in command, so it's documented in the Bash manual.
还有一个外部命令可以执行相同的操作;在许多系统上,它是由GNU Coreutils软件包提供的.
There's also an external command that does the same thing; on many systems, it's provided by the GNU Coreutils package.
[
与test
命令等效,除了[
要求]
作为其最后一个参数,而test
不需要.
[
is equivalent to the test
command, except that [
requires ]
as its last argument, and test
does not.
假设系统上已安装bash文档,如果键入info bash
并搜索'test'
或'['
(撇号是搜索的一部分),则将找到[
的文档.命令,也称为test
命令.如果使用man bash
而不是info bash
,请搜索^ *test
(在行首的单词test
,后跟一些空格).
Assuming the bash documentation is installed on your system, if you type info bash
and search for 'test'
or '['
(the apostrophes are part of the search), you'll find the documentation for the [
command, also known as the test
command. If you use man bash
instead of info bash
, search for ^ *test
(the word test
at the beginning of a line, following some number of spaces).
在引用"Bash条件表达式"之后,您将获得对-ne
的描述,这是数字不等式运算符("ne"代表不等于".相反,!=
是 string 不等式运算符.
Following the reference to "Bash Conditional Expressions" will lead you to the description of -ne
, which is the numeric inequality operator ("ne" stands for "not equal). By contrast, !=
is the string inequality operator.
您还可以在网上找到bash文档.
You can also find bash documentation on the web.
- Bash参考
- Bourne shell内置程序(包括
test
和[
) - Bash条件表达式-(滚动到底部;
-ne
在" arg1 OP arg2 "下) -
test
的POSIX文档
- Bash reference
- Bourne shell builtins (including
test
and[
) - Bash Conditional Expressions -- (Scroll to the bottom;
-ne
is under "arg1 OP arg2") - POSIX documentation for
test
test
命令的官方定义是POSIX标准(bash实现应相当好地遵循它,也许还会有一些扩展).
The official definition of the test
command is the POSIX standard (to which the bash implementation should conform reasonably well, perhaps with some extensions).
这篇关于"-ne"是什么意思?卑鄙的意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!