0

I have text file with a lot of text in it, and I would like to sort every word one below other how can I do that. For ex.

cat PDF | less
word one, word two. Word three ?

I need them to be

word
one
word
two
Word
three
3

This isn't really what I would call sorting.

You could either squeeze and transliterate all non-alphabetic sequences into newlines

tr -sc '[:alpha:]' '[\n*]' < PDF

or (at least with GNU grep) match and output sequences of word characters (alpha, decimal digits and underscore), one per line using the -o option

grep -o '\w*' PDF

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.