If you don't mind words running together where you join the lines, try this command:
echo -e 'g/\<remotely\>/.,/\<p_args\>/j\nwq' | ed -sl filename
Example input and output follow.
$ cat a
"Yes, and to be grown up,
my child, to venerate him,"
replied Glenarvan, deeply
touched by the boy's genuine
affection.
During this conversation the
horses remotely had been slackening
speed, and were only walking
now.
"You will find him?" said
Robert p_args again, after a few
minutes' silence.
"Yes, we'll find him," was
Glenarvan's remotely reply, "Thalcave
has set us on the track,
and I have great p_args confidence
in him."
"Thalcave is a brave Indian,
isn't he?" said the boy.
"That indeed he is."
$ echo -e 'g/\<remotely\>/.,/\<p_args\>/j\nwq' | ed -sl a
$ cat a
"Yes, and to be grown up,
my child, to venerate him,"
replied Glenarvan, deeply
touched by the boy's genuine
affection.
During this conversation the
horses remotely had been slackeningspeed, and were only walkingnow."Yo
+u will find him?" saidRobert p_args again, after a few
minutes' silence.
"Yes, we'll find him," was
Glenarvan's remotely reply, "Thalcavehas set us on the track,and I hav
+e great p_args confidence
in him."
"Thalcave is a brave Indian,
isn't he?" said the boy.
"That indeed he is."
$
If you do mind the words running together, you may need a two-pass solution, eg.
for t in 's/$/ /' j; do echo -e 'g/\<remotely\>/.,/\<p_args\>/'"$t"'\n
+wq' | ed -sl filename
(Update: added double quotes in the above.)
(Update: a bit better than the above would be
g='g/\<remotely\>/.,/\<p_args\>/'; echo -e "${g}s/\$/ /\n${g}j\nwq" |
+ed -sl filename
)
or some other method, such as
ex -c $'g/\<remotely\>/.,/\<p_args\>/j\nwq' filename
Update: uh, I see only now that your terminator is "p_agrs", whereas I thought it was "p_args". I might replace them later in this node, but for now, you'll have to do the replacement yourself.
Update: did someone mention perl -wpe 'if (/\bremotely\b/.../\bp_args\b/) { chomp }' above? They probably didn't only because they interpreted your question differently.
See Re^2: Joining two files on common field for a list of nodes where unix textutils is suggested to merge files.