ls -al | grep "^d" | grep "\." | tr -s " " | cut -d" " -f8
The "ls" lists all files. The first grep chooses the directories only and not files. Remove this to select hidden files too. The second grep selects hidden files - files tarting with a “dot”. It has to be escaped with \ otherwise it matches all characters. tr compresses extra spaces in the listing. “cut” selects the last column which is the hidden directory names. Without the tr compressing the delimiting spaces “cut” will mistake extra spaces to be new columns so the penultimate step is crucial.