How do I get awk to parse a file so each word goes on a new line?

Sometimes you want to parse a file so each word, or field, goes on its own separate line. For example:

The time has come the Walrus said,
to talk of many things.

would become:

The
time
has
come
the
Walrus
said,
to
talk
of
many
things.

A method of doing this with awk is the command:
cat file | awk '{print $0}' RS=' '

If the words or fields are separated by something other than spaces, you can stick that in RS in stead.

Back to tech tips