I currently have a log file and I have to filter the information to get the longest word ending in several characters using the "grep" command.
For example, I have to find the words ending in "abc".
And I have the following file:
XXXXXabc
YYabc
ZZZdef
XXabc
The correct output should be:
XXXXXabc
Until now I had tried with the following:
grep -E '\abc' log.txt | wc -L
But this returns the maximum length without showing the word. How can I make the word print on the screen?
Thank you!