array=${ls -d */} echo ${array[@]}
I have three directories: ww ee qq. I want them in an array and then print the array.
ww
ee
qq
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.
1.4m articles
1.4m replys
5 comments
57.0k users