1

* means all files and directories including files in sub directories.

/ means in root directory

ls */ brings files in sub directories in current directory (not includes files in current directory)

ls -d list directory entries instead of contents. My directory full of files and sub directories. Why in my case this brings only ./ ?

By adding all together I have ls */ -d. It brings all directories in current directory. What is logic of this combination? If I take separate parts of this command listed it not brings such result.

6

/ doesn't mean root directory. It's a path separator. If the path begins with /, then of course, you have an absolute path, which starts at the root level. Here, the slash comes after *. The asterisk globs all the entries of the current directory, but here, the pattern is */: everything in the current directory that ends on a /; files don't end on /, but ending a path with a slash means you specified a directory, so this only means directories. Compare with *.txt which would mean all entries ending with .txt.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.