Find A Sub-Word

  • + 0 comments

    Bash :

    #!/bin/bash
    
    read count
    allString=""
    for (( i=1; i<=$count; i++ ))
    do
        read string 
        allString+="$string " 
    done   
    
    read subWordInt
    for  (( i=1; i<=$subWordInt; i++ ))
    do
        read subSequent
    echo "$allString" | grep -o -E "\B($subSequent)\B" | wc -l
    done