Extract words from files

How can I extract all the words from a file, every word on a single line? Example:

test.txt

This is my sample text

Output:

This
is
my
sample
text

Answers


The tr command can do this...

tr [:blank:] '\n' < test.txt

This asks the tr program to replace white space with a new line. The output is stdout, but it could be redirected to another file, result.txt:

tr [:blank:] '\n' < test.txt > result.txt

Need Your Help

Does Passing STL Containers Make A Copy?

c++ c++11

I can't remember whether passing an STL container makes a copy of the container, or just another alias. If I have a couple containers: