I'm listing files and sorting them. When I try to get length of array variable in which these files are stored I get 1 as value. That's weird.
files_info="$(find $input_dir -name "*_CHR$i.info" | sort )"
printf ${#files_info[@]}"\n" #print length
#--loop through array - it works fine
for x in ${files_info[@]}
do
printf "$x\n"
done
When I loop through the array it works fine. But when I want to print length of array it print 1.
When I debug it with -x, I see '\n'
May be new line character is messing length?
You're not assigning an array but a scalar variable, thus the result 1 is correct. Unfortunately, you don't mention your environment, so I can't tell you how to define an array.