通过其绝对文件路径运行linux命令

穆罕默德·瓦泽姆

输出我知道我们可以通过Unix或Linux命令的绝对文件路径以及命令本身来调用它。例如,我们可以通过键入ls以及/bin/ls(在Linux中)列出目录内容,有什么区别吗?当我这样做时,我得到了相同的输出,但是在文件类型之间的颜色分离上只有区别,您可以在上载的图像中看到它。

库萨兰达

Giving the command ls at the prompt would do a bit more than just call /bin/ls. If ls was an alias or a function, that alias or function would be called. If it was neither, and if it furthermore was not a built-in command (ls is very rarely a built-in command), then a path search would be performed for ls in each directory in the :-delimited list in the $PATH environment variable.

The ls that was first found in $PATH would be executed. This could potentially be another ls than /bin/ls if a directory that contained such a name was located earlier than /bin in the $PATH list.

使用/bin/sh将绕过别名和函数查找以及其中的任何查找,$PATH而是直接运行该命令。

在输出的色差之间ls/bin/ls可能会因来解释ls作为一个别名调用时增加了额外的命令行选项ls实用程序(检查用alias lstype -a lsbash)。

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

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

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章