ls typically displays only the files and folders in the present directory. But once you add a wildcard it starts searching in sub-directories.


$ ls
fight_folder    file1       file2

$ ls f*
file1   file2


How do you limit the scope to only the current directory?
Using OS X


ls -d suppresses listing the contents of directories listed on the command line (via the wildcard). From the documentation:

-d Directories are listed as plain files (not searched recursively).

  • ls -d * does what you say but unfortunately ls -d does not list directories. – aless80 Jul 14 '17 at 13:47

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.