Issue
I have the following data file:
Name: ABC
Address: 123, 4th Street,
My County,
10009 Country.
Age: 34
Gender: Male
Name: DEF
Address: 456, Orange Street,
North State,
45678 Country.
Age: 68
Gender: Female
Basically, each record is separated by 2 empty lines. The problem is some "Address" will contain 2 empty lines too (see example above).
How can I replace the valid "2 empty lines" separator with say "#####", but leave the 2 empty lines in the "Address" field untouched (as is)?
Thanks.
I tried various "sed" commands with N options and "awk" commands, but nothing works so far :(
Solution
Assuming that each record ends with a Gender:
line then you can do something like:
awk '{if(NR<=n)next;print $0}/Gender/{print"######";n=NR+2}' yourfile.txt
Answered By - JNevill Answer Checked By - Timothy Miller (WPSolving Admin)