Given a file, for example:
potato: 1234 apple: 5678 potato: 5432 grape: 4567 banana: 5432 sushi: 56789
I\'d like to grep for all lines that
Modern BASH has support for regular expressions:
while read -r line; do if [[ $line =~ ^potato:\ ([0-9]+) ]]; then echo "${BASH_REMATCH[1]}" fi done