regex - Match multiple lines of a file and replace if content does not match -


i have particular file(sample.txt) content :

doc=true     add=123.566.33.8     #is sample file     use #for specific functions     domain=443.59.43.23 

upon performing operation, content of file changes :

doc=true add=123.566.33.8 eshfsjfn sldfhsehfoewjwefn lsjdnfnfd 

now need make sure content remains in first case. i'm trying grep initial pattern(sample.txt) using grep command required lines , if in case lines not match, should append these lines in file sample.txt . content in sample.txt should limited shown initially. don't want create file same content , match them. want use grep, sed or perhaps awk.

i post answer assuming want sample.txt checked against standar awk file entrance

hope can you

awk'begin {   while (getline < "sample.txt")   {     a[$0]   } } {     if( $0 in a)     {         located=true;     }     if(!located)     {         print "line changed ->"nr" ->"$0         print $0 >> "sample.txt"  <-- printing located line in sample.txt         located=false;     } }' file2.dat 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -