我的“ / bin”文件夹中的“ [”二进制文件是什么?(MacOS Big Sur M1芯片)

Jun Yin

我是Operating System的新手,并尝试通过探索我的新计算机来赶上来。

今天早上,我只是在浏览bin文件,我看到了一个奇怪的文件夹“ [”。这是什么?在此处输入图片说明

我还没有在“ / bin”文件夹中创建或安装任何东西。所以它不是我创造的。我的“ / bin”文件夹中的“ [”二进制文件是什么?

在此处输入图片说明

萨加尔

[是测试程序。正如手册页所建议的那样,

[ condition ]

and evaluates to either a zero (for true) or a non-zero value (for false). In the case of zsh on macOS, the man page says that false is represented by 1. Note that the whitespace after the square bracket is important since that whitespace indicates to the shell that you want to run the [ program.

Despite the presence of the program, that executable is probably not used often. It appears that you're using zsh, which is the default shell on macOS. In zsh, [ is a built-in which takes precedence over /bin/[. This can be verified by

% which -a [
[: shell built-in command
/bin/[

The man page for the built-in can be found by man zshbuiltins.

If you want to explicitly use the program in /bin, then your command should look like

/bin/[ condition ]

Example

假设您正在运行要检查条件的Shell脚本。例如,您要检查文件是否存在。[通常用于此目的。这是一个例子

if [ -f myFile.txt ]; then
   date > myFile.txt
else
   echo "File was created on $(cat myFile.txt)."
fi

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在MacOS Big Sur(M1芯片)上安装自制软件时收到警告

我的文件夹中的.rnd二进制文件是什么?

我的go二进制文件最终位于src文件夹中

如何使用 SSH 从 /usr/local/bin 运行二进制文件到运行 macOS BigSur (11.2) 的 MacBook Pro M1?

我的$ HOME / bin文件夹中的sudo脚本

无法在 macOS Big Sur (Apple M1) 上保护 MariaDB 安装

GraalVM 在 macOS Big Sur (Apple m1) 上安装失败

Macbook Pro 2020 M1 - MacOS Big Sur - Homebrew 不工作

xampp 无法在 mac Big Sur 中打开时如何访问 htdocs 文件夹?

无法运行 composer install。在 mac Big Sur M1 中获取 php-mongodb 错误

MacOS中二进制文件的全局目录的路径是什么?

为什么我必须使用ld链接我的二进制文件

为什么我的系统只在 /snap 中查找二进制文件?

为什么git认为我的.sql文件是二进制文件?

为什么我不能将二进制文件的输出重定向到文件?

为什么我的文本文件比二进制文件大?

是什么使grep认为文件是二进制文件?

找不到“ yo”二进制文件。确保已安装它并在$ PATH中。你能告诉我问题是什么吗?

我可以调用什么工具/二进制文件来确定nVIDIA GPU的计算能力?

担心无法在我的二进制文件中加载什么?

为什么编译后我们不能理解二进制文件的内容?

为什么我会执行二进制文件错误?

为什么我不能从/ home路径运行二进制文件

为什么我编译的 C++ 二进制文件不能执行?

如果我自己构建一个OpenDJ二进制文件与VS Forgerock Enterprise发布的二进制文件有什么区别?

我如何获得lshal二进制文件?

我的二进制文件以相反的顺序输出

当通过 ssh 检索二进制文件时,是什么导致 \r's 被插入到 \n's 之前,我该如何规避它?

我编译器生成的二进制文件不仅仅包含二进制数,为什么?