Remove newlines between two words
问题 I have a file that looks like: name: charles key1: how are you? name: erika key2: I'm fine, thanks name: ... How could I remove the new lines that between "key\d+" and "name:"? It should look like this: name: charles key1: how are you? name: erika key2: I'm fine, thanks name: ... I'm trying to use sed or awk but without any success. Is there any way to clean that lines? Is there any way to remove the newlines between "key\d+:" and "\w+:"? 回答1: something like this? kent$ awk '/^key.:/{p=1}/