I would like to compare the two last lines from the txt file. While it looks like comparing line by line is out there - found few examples - I cant seem to find the way of comparing always the last two lines. And both of those lines will always contain simple set of characters so its like comparing strings. Thank you!
EDIT: What I'm actually trying to achieve might make this question irrelevant so let me explain. I have a script which produces some string value. Now, this script is being run by crontab on daily basis and its output is saved to a new file. Whenever there's a change to the string the file should be updated with it and new file with a new value should be created which records the date of when the new value was created . Since as far as I know crontab jobs are not conditional, I just can't figure it out how I could achieve this goal with not adding a string to the same file and comparing it with a previous line's string . I know that's not the best way since the file will keep growing - but I can always run some clean up (automate it) - however I don't know the other way. And of course the check of those 2 lines would be done by a 2nd script which would be run by 2nd crontab job which would run after the daily 1st job .. I hope the explanation makes sense. Thank you !