Skip to content
Advertisement

compare two words, 1st word = file name appended with date and 2nd word = just date alone. compare should display the lines with different date [closed]

I am writing a script to compare the file name appended with date(YYY-MM-DD) with date of the file modified.

Example:

filename.2019-01-07.log   2019-01-09
filename.2019-01-07.log   2019-01-07
filename.2019-01-07.log   2019-01-07

Output:

filename.2019-01-07.log 2019-01-09

compare above two words with dates and display the file that has different dates.

please let me know the possible ways to perform this

Thanks

Advertisement

Answer

Delete every line that has a pattern repeated:

sed -r '/([-0-9]{10}).*1/d' input

or more accurate

sed -r '/([0-9]{4}-[0-9]{2}-[0-9]{2})[.]log.*1/d' input
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement