I am looping though a directory for a certain command; however, I do not know how to accommodate for spaces
#!/bin/bash
image=(`ls *.bmp *.jpeg *.jpg | sort`)
data=(`ls *.dat | sort`)
for ((i=0; i < ${#image[@]}; i++))
do
echo ${image[$i]} ${data[$i]}
done
I ran this script and it returned
OIS032_OS.bmp Disc
OIS034_OS.bmp Cube
OIS035_OD.bmp 200x200_9-30-2010_OD
OIS035_OS.bmp _ILM_RNFLOb.dat
OIS036_OD.bmp OIS007_Optic
OIS036_OS.bmp Disc
I wanted the program to return this line
OIS016_OD.bmp OIS016_Optic Disc Cube 200x200_OS _ILM_RNFLOb.dat
How do I fix bash array to store what I need
data=(`ls *.dat | sort`)