Wildcard expansion is done by the shell, and (in a POSIX sh at least) there's no way to tell the shell to check permission and file type bits when it expands * into a list of names. In fact, not only is there no such option there cannot be such an option. So -d is not a "print only directories" option. ![]() So ls prints out the information for each of the directories that is passed as its arguments, just as it would do if they were files. With the -d option, directories are treated just like files. For arguments that name files, it just prints out the information for the file itself. What normally happens next is that ls looks at each of its arguments in turn, sees that they are directories, and decides to enumerate their contents. What the -d/ -directory option does is turn off what normally happens next. What the ls command itself receives from the shell is (something like) ls bin home opt var boot dev tmp etc lost+found root usr On Unices and on Linux, wildcard expansion is done by the shell, and is oblivious to permissions. (On some operating systems, the attribute filters can be given to the system call for enumerating a directory and the operating system kernel, or its filesystem drivers, applies them itself.) dir expands wildcards like *, which the command interpreter passes to it as-is, and if /a is specified it applies the appropriate filters to what is returned. ![]() ![]() On MS-DOS, Windows, and indeed a few other IBM/Microsoft operating systems, wildcard expansion is done by the command itself, and things like the /a option to the dir command act as attribute filters during wildcard expansion. Your expectations are based upon DOS Think/Windows Think and are wrong.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |