jeudi 1 octobre 2020

how to capture only digits in array using if statement in bash

    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
     

Aucun commentaire:

Enregistrer un commentaire