Don’t use ls, it’s not intended for this purpose. Use globbing.
shopt -s nullglob
array=(*)
array2=(file*)
array3=(dir/*)
The nullglob option causes the array to be empty if there are no matches.
Don’t use ls, it’s not intended for this purpose. Use globbing.
shopt -s nullglob
array=(*)
array2=(file*)
array3=(dir/*)
The nullglob option causes the array to be empty if there are no matches.