bash script space question

Status
Not open for further replies.

dualblade

Supreme [H]ardness
Joined
Nov 19, 2000
Messages
4,180
i'm trying to read the contents of a directory into an array, but i'm not sure how to deal with subdirectories that have spaces.

the code i've got is like this:

Code:
for dir in `ls  /vmstorage/`
do
list[count]=$dir
echo "$count: $dir"
count=$((count+1))
done

if the subdirectory has a space, the text after the space will become a new array position. i know strings can handle having spaces, but i'm not sure how to do this correctly. any advice?
 
Status
Not open for further replies.
Top