Reputation: 17
How can I create an array consists of folder names? For example, I have set of folders with names A, B, C, and I want to create the array arr=(A B C).
I tried this:
arr=$(ls ~/Desktop/C\ study/seydtb )
But after that when I create files using this arr
for ((i=0; i<${#arr[@]}; i++)); do
touch ${arr[$i]}.sey
I get this:
A B C.sey
Only the last one has the .sey
suffix.
Upvotes: 0
Views: 44
Reputation: 23866
Do not use ls
, if you need globbing.
a=(~/Desktop/C\ study/seydtb/*)
for i in "${a[@]}"; do
echo $i
done
Upvotes: 2