Grep command to extract unique words

grep, linux

Solution

Display only the unique words starting with `temp`:

$ grep -o '\btemp\w*' file | sort -u
temp1
temp2
temp3
tempabc

Problem

Here is my file. ``` this is temp1 this is temp2 this is temp3 this is temp1 this is tempabc ``` How to use grep command that while looking for pattern 'temp', the result should be displayed as only 'temp1, temp2, temp3, tempabc', only unique words. Thanks

Original source