I have two files in unix, I need the difference between them. Simple enough diff will do. But I also need the name of the section that was edited, which is the name of the group.
File 1:
GROUPNAME = {"hostnames","morehostnames","alotreally",
"almost200","hosts","separated"
,"ingroupsof3"};
File 2:
GROUPNAME = {"hostnames","morehostnames","alotreally",
"almost200","hosts","separated"
! ,"ingroupsof3","addedthis"};
Sofar I have this:
diff -C 150 file1 file2 | awk '/= {/,/!/p' >> diff.txt
Since I don't know how many hosts are in a group, I can't use exact numbers, only patterns.
diff
shows me the 150 lines as requested, the changes between the two are highlighted with "!".
With the command above I get the start of the group:
GROUPNAME = {"hostnames","morehostnames","alotreally",
but it stops at the first line feed. I would like to get the whole group including the lines marked with '!' (which would be the change itself).
I tried sed, gave me roughly the same result. Thanks in advance!
` part of the file or do you just want to indicate a new line? If the latter, remove the `
` – kvantour Apr 10 '18 at 08:25