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.
More Related Contents:
- Loop through an array of strings in Bash?
- How to sort an array in Bash
- How to pass array as an argument to a function in Bash
- Arrays in unix shell?
- Reading a space-delimited string into an array in Bash
- Convert command line arguments into an array in Bash
- I am getting error “array.sh: 3: array.sh: Syntax error: “(” unexpected”
- How to find the length of an array in shell?
- Check if an element is present in a Bash array [duplicate]
- Check if a Bash array contains a value
- Creating an array from a text file in Bash
- Reading output of a command into an array in Bash
- How can I store the “find” command results as an array in Bash
- How can I join elements of an array in Bash?
- Passing arrays as parameters in bash
- Iterate over two arrays simultaneously in bash
- Capturing output of find . -print0 into a bash array
- Multi-dimensional arrays in Bash
- Remove an element from a Bash array
- How to return an array in bash without using globals?
- Accessing a JSON object in Bash – associative array / list / another model
- Print array elements on separate lines in Bash?
- Bash indirect array addressing?
- How to check if element exists in array with jq
- Convert multiline string to array [duplicate]
- How to pass an array argument to the Bash script
- Assign to a bash array variable indirectly, by dynamically constructed variable name
- How to merge two arrays in a zipper like fashion in Bash?
- How to get file creation date/time in Bash/Debian?
- How to copy an array in Bash?