len=${#newarray[*]}
for ((i=0;i<${len};i++)); do
if [[ "${newarray[$i]}" =~ ^[[:digit:]]+$ ]]; then
echo "${newarray[$i]}"
fi
this is my code I need to get only digits from the array list and their count as well. but there is an issue that shows alphabetical values only.
given getdata.txtcontains -
cat
dog
1234
pl345
567ab
12234
if/elseis backwards. You should do theechoin theifandcontinuein theelse, sinceifmatches numeric values.newfoldersinstead ofvalue?leninfor ((i=0;i<len;i++)); do(variables are automatically expanded within(( ... )))