# download the zip file from https://www.rand.org/pubs/monograph_reports/MR1418.html (zip file) # then compact the lines with awk and pick those that have, for example, at least 5 times or more the numbers 5 to 9. awk '{ local_string=($2 $3 $4 $5 $6) print local_string } ' digits.txt | head -10 | grep -E '[5-9]{5,}'