-1

I have a listing of files that have numeric characters at the end after a dot.

ex :

abc.log
abc.log.1
xyz.log
xyz.log.1
xyz.log.2

I need to list only the logs that have .log at the ending and not the ones with .log.1 or .log.2 at the ending.

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
  • https://www.regular-expressions.info/wordboundaries.html – steeldriver May 17 '19 at 12:21
  • "I need to list only the logs..." "GREP only xyz.log not xyz.log1" Are you asking how to grep them or how to list them? # grep searchterm *.log or # ls *.log would do this? Or are you asking something else that I'm not understanding? – Kefka May 17 '19 at 12:39
  • I think it's a listing in a file, otherwise the Q doesn't make sense ... – pLumo May 17 '19 at 12:48
  • @pLumo oh yeah, I think you're right. I read his question as asking how to perform a simple grep or ls in a log directory. Yours makes more sense. – Kefka May 17 '19 at 12:54

1 Answers1

4

Use $ for end of line :

grep '\.log$'
pLumo
  • 22,565