I am new to shell scripting and wanted to list only the directories present in my present working directory.
To do this I found out the following way:-
ls -d */
Based on my understanding , this command will search for entities in pwd` that ends with "/" , but there is nothing in my directory that ends with "/", So, how does this expression works?
Also when I do simply do
ls -d
why does it simple show a ". " on the terminal
*/
is shell glob pattern that only matches directories in the current directory.
You can even get similar output using:
echo */
ls -d
just formats it differently.
As per man ls
:
-d Directories are listed as plain files (not searched recursively).