Skip to main content
deleted 2 characters in body
Source Link
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'A-Za-z_]'z_' '[\n*]' < file | ...

On historical System V systems, you need to use square brackets [A-Za-z_].

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 | ...

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 | ...

On historical System V systems, you need to use square brackets [A-Za-z_].

deleted 2 characters in body
Source Link
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 | ...

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 | ...

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 | ...
POSIXified
Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k

It depends on how you define words.

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

tr -s '[[:blank:]]' '\n''[\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 | ...

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 | ...

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 | ...
Source Link
cuonglm
  • 158.1k
  • 41
  • 341
  • 419
Loading