I have a file with the following content:
dn : Does not matter
uid=321 456 678
foo=/234
bar=/456
git=/543
uid=321 456 678
uid=678 987 098
foo=/234
bar=/456
git=/543
dn : Does it matter
uid=321 456 678
foo=/543
bar=/423
git=/501
I want to remove any occurrences of uid=
that occurs consecutively and also the 3 lines following it so that the expected output is:
dn : Does not matter
uid=321 456 678
foo=/234
bar=/456
git=/543
dn : Does it matter
uid=321 456 678
foo=/543
bar=/423
git=/501
I have tried that on two servers. Unfortunately, I do not have access to the one server where I had tried the bulk of my attempts. So from the second server I have tried variations of the following but desired results are eluding me.
sed '/^ uid=/N;{/\n uid= & & \n ^change type & & \n ^replace/d;}' pattern2.txt
awk '{/pat/?f++:f=0} f==2 {f--;}; 1' < pattern2.txt
sed '/^ uid=/N;{/\n uid=/D;}' pattern1.txt
awk '{/ uid=/?f++:f=0} f==2' pattern1.txt
ctrl+k
or press the{}
editing icon)uid=
? if so, using awk's paragraph mode is the easiest way to solve thisawk -v RS= -v ORS='\n\n' '!/uid=.*uid=/'
solves your problem? this works for given sample but might not work for your real use case