I'm trying to write a Bash script that will read a text file and pull out every word that is followed by a comma on a new line. I tried using
grep
awk
The Veterinary clinic treats the following animals: dogs, cats, and birds
dogs,
cats,
Looks like you need to know about grep
's -o
parameter (only matching). If you consider a word to be a series of letters separated by spaces than this match will do:
grep -o "[a-zA-Z]\+," file