[Bash] Store the output of ls in an array

Created on November 28, 2026

You can combine command substitution with Bash's array initialization syntax to store the output of ls in an array. This example assigns the results to the files variable.

files=( $(ls -1) )
Bash Shell command