I am looking for advance two file compare shell/bash/php. Let say i have such files:
file1
.run file=test_script.sql rev=1.1
.run file=test_sql.sql rev=1.1
.run file=test_drop.sql rev=1.2
file2
.run file=test_drop.sql rev=1.2
.run file=test_grant.sql rev=1.1
.run file=test_script.sql rev=1.2
get the difference between those files (ignoring line order) that is
.run file=test_grant.sql rev=1.1 #(because new line wasn't in file1 at all)
.run file=test_script.sql rev=1.2 #(because rev changed from rev=1.1 to rev=1.2)
but that is not all, i want to check if there was same (.run file=name) in the old file and if it was then get it's (rev=number). So that the final output will look like this:
file3:
test_grant.sql 1.1 1.1
test_script.sql 1.1 1.2
so far:
fgrep -x -v -f file1 file2
gets
.run file=test_grant.sql rev=1.1
.run file=test_script.sql rev=1.2