ls only files or directories examples in linuxOctober 16, 2019Test dir linux ls only directoryFirst way➜ ls -d */-d Directories are listed as plain files (not searched recursively). */ is a pattern that matches all of the subdirectories in the current directory (* would match all files and subdirectories; the / restricts it to directories). Reference：https://stackoverflow.com/questions/14352290/listing-only-directories-using-ls-in-bash-an-examination Second way: using linux ls and linux grep command ➜ ls -l | grep "^d"Third way：using linux find command➜ find . -type d -maxdepth 1linux ls only filesFirst way ➜ ls -l | grep -v "^[d|l]" ➜ ls -l | grep "^-"Second way: using linux find command➜ find ./ -type f -maxdepth 1Tags:linux ls command, ls dir, ls filesAdd a Comment Cancel replyYour email address will not be published. Required fields are marked *Comment Save my name, email, and website in this browser for the next time I comment.