How to find all words that end in a period?

I have a file containing many words ending in ., most of which are abbreviations, for example:

  • and etc.
  • ps

How can I display a list that displays all these words only once?

  • All words have a space before, so this space can be used to find the beginning of a word.
  • Not a word appears at the beginning of the line.
  • There are no sentences in the file, so all periods are used in this way.
+3
source share
3 answers

One way to do this:

egrep -o '\b[^ ]+\.' < list_of_words | sort | uniq
+3
source

If you have GNU grep, use Perl-compatible regular expressions: grep -Po '\S*\.(?=$|\s)'

+2
source

:

egrep -io ' [a-z.]+\.' input_file | sort -u
+1

All Articles