I want to find out what was added to a log file between 2 tasks. Right now the way I do it is:
content of test.log initially
aaa
bbb
saving content of the log
$ cp test.log test.log.before
doing something
content of test.log after doing something
aaa
bbb
ccc
saving content of the log
$ cp test.log test.log.after
showing the difference
$ diff test.log.before test.log.after
2a3
> ccc
What I don't like with this method is that I get some noise from diff
(2a3
and >
) whereas I just want ccc
.
Q: Is there a way I can just get the difference between the 2 log files (i.e. what is new in test.log.after, ccc
)?
I had a look at diff's man page but I don't see anything obvious there.
If you always do a before and after such that the end of the after file will contain the new content then you could use comm.
If you want to get the additions only you can filter the output such as:
However, you will lose the deletions if any.