"ls"命令在Linux/Unix中如何工作?

问题描述:

我想确切地知道"Is"命令在Linux和Unix中的工作原理.

I would like to know exactly how the "Is" command works in Linux and Unix.

据我所知,ls fork& exec到Linux/Unix shell,然后获取(当前文件树的输出,例如/home/ankit/).我需要更详细的说明,因为我不确定调用fork之后会发生什么.

As far as I know, ls forks & exec to the Linux/Unix shell and then gets the output (of the current file tree. eg./home/ankit/). I need a more detailed explanation, as I am not sure about what happens after calling fork.

任何人都可以详细解释'ls'命令的功能吗?

Could anyone please explain the functionality of the 'ls' command in detail?

ls不分叉. Shell会分叉并执行,以便运行任何未内置的命令,并且它可以运行的命令之一是ls.

ls doesn't fork. The shell forks and execs in order to run any command that isn't built in, and one of the commands it can run is ls.

ls使用opendir()和readdir()逐步浏览目录中的所有文件.如果需要有关它们之一的更多信息,请调用stat().

ls uses opendir() and readdir() to step through all the files in the directory. If it needs more information about one of them it calls stat().