1.

How Do I Join Two Lines If Line #2 Begins In A [certain String]?

Answer»

Suppose a line begins with a particular string. How do you bring that line up to follow the previous line In this example, we want to match the string "&LT;<=" at the BEGINNING of one line, bring that line up to the end of the line before it, and REPLACE the string with a single space:

SED -E :a -e '$!N;s/n<<=/ /;ta' -e 'P;D' file # all seds
sed ':a; $!N;s/n<<=/ /;ta;P;D' file # GNU, ssed, sed15+

Suppose a line begins with a particular string. How do you bring that line up to follow the previous line In this example, we want to match the string "<<=" at the beginning of one line, bring that line up to the end of the line before it, and replace the string with a single space:

sed -e :a -e '$!N;s/n<<=/ /;ta' -e 'P;D' file # all seds
sed ':a; $!N;s/n<<=/ /;ta;P;D' file # GNU, ssed, sed15+



Discussion

No Comment Found