Diff two files in shell script -
assume have 2 files named file1 , file2.
file1: a=b c=d e=f file2: a=p c=o e=f g=h i=j
here file2 has same keys of file1 , different values.apart key-value pair of own.
compare 2 files keys, replace file2 value file1 value based on key match. retain new entries in file2.
so, final output should :
file2: a=b c=d e=f g=h i=j
thanks in advance.
quickest way without using scripts using tool called "meld".
can give 1 way of approaching problem (though not best)
1.read first file line line
2.split based on "=" expression
3.store 2 variables key , value make array of key value pairs
4.read second file , repeat procedure
compare 2 arrays , save values not in first array
in specific case can use "cut" command in shell choose fields . prefer perl script file operations :)
Comments
Post a Comment