Reputation: 3521
I have one pattern
cat sample.text
\newline</Text>
I'm using the following command:
sed ':a; N; $!ba; s|\newline</Text>|</Text>|g' sample.text
but following command is not working.
Upvotes: 0
Views: 195
Reputation: 203358
Are you just trying to get rid of the newlines before </Text>
? That's just a simple substitution:
gawk -vRS='\0' -vORS= '{gsub(/\n<\/Text>/,"</Text>")}1' file
Upvotes: 2
Reputation: 58391
This might work for you (GNU sed):
sed '$!N;s/\n\(<\/Text>\)/\1/;P;D' file
or
sed -r '$!N;s|\n(</Text>)|\1|;P;D' file
However if \newline
is a literal:
sed 's/\\newline\(<\/Text>\)/\1/g' file
or
sed -r 's|\\newline(</Text>)|\1|g' file
Would work just as well.
Upvotes: 2
Reputation: 3521
I just found solution myself so thought to share with everyone.
sed ':a; N; $!ba; s|\\newline<\/Text>|</Text>|g' sample.text
Upvotes: 0