Skip to main content
3 of 4
deleted 2 characters in body
cuonglm
  • 158.1k
  • 41
  • 341
  • 419

It depends on how you define words.

If words are separated by one or more spaces, you can do:

tr -s '[:blank:]' '[\n*]' < file |
  while IFS= read -r word; do
    : echo "$word" here
  done

If words are sequences of characters contains A-Z, a-z and _:

tr -cs '[A-Za-z_]' '[\n*]' < file | ...
cuonglm
  • 158.1k
  • 41
  • 341
  • 419