Display lines for a particular year in a file using grep

hi,

I have a log file with data for more than 3 years, i want only the rows for the year 2017, say for example.

My file has the data like this

08-OCT-2015 11:17:35 AAA, BBBB

08-OCT-2017 11:17:35 AAA,Bdfdfd,dfdfd,dfd

08-Nov-2017 11:17:35 AAA,Bdfdfd,dfdfd,deree

i want the rows with the year 2017, so my output should be 2 rows like this

08-OCT-2017 11:17:35 AAA,Bdfdfd,dfdfd,dfd

08-Nov-2017 11:17:35 AAA,Bdfdfd,dfdfd,deree

i was using a grep with data function but it never returned any rows.

Thanks in advance,

grep "^[^ ]*-2017 " logfile
1 Like

Thanks a lot Sir, its working now