Special parameter "$@" contains the following string variables,
echo $@ outputs: a.bdf, b.bdf,c.nas,d.nas
I want to extract the string variables with extension 'bdf' and save it in another array. Is it possible to do so in bash?
Just iterate through it with a for loop :
for ARG in "$@";do
if [[ "$ARG" == *.bdf ]];then
BDF_ARRAY+=("$ARG") #you don't need to initialize this array before the loop in bash
else #optional block, if you want to split $@ in 2 arrays
OTHER_ARRAY+=("$ARG")
fi
done
echo ${BDF_ARRAY[@]}
echo ${OTHER_ARRAY[@]}
,and ` ` (space) between values. Are the,being part of the data or only separators?