linux list folders code example

Example 1: list only directories

# List directories under the current working directory.
ls -l | grep "^d"

# List directories under the current working directory and 
# include hidden folders
ls -la | grep "^d"

Example 2: display all files in a directory linux

ls command list computer files in a directory in Unix OS with next structure:
ls [OPTION]... [FILE]...
Examples:
ls -l #display all files in current directory with  (-l) long format.
ls -a /directory #display all hidden files in given directory that start with .

Example 3: list all files in a directory and subdirectory linux

find . -type f -follow -print