array=${ls -d */}
echo ${array[@]}
I have three directories: ww
ee
qq
. I want them in an array and then print the array.
It would be this
array=($(ls -d */))
EDIT: See Gordon Davisson's solution for a more general answer (i.e. if your filenames contain special characters). This answer is merely a syntax correction.