How do I assign ls to an array in Linux Bash?

前端 未结 3 1098
孤街浪徒
孤街浪徒 2020-12-01 00:50
array=${ls -d */}
echo ${array[@]}  

I have three directories: ww ee qq. I want them in an array and then pr

3条回答
  •  旧巷少年郎
    2020-12-01 01:49

    This would print the files in those directories line by line.

    array=(ww/* ee/* qq/*)
    printf "%s\n" "${array[@]}"
    

提交回复
热议问题