Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
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.
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:
\newline
sed 's/\\newline\(<\/Text>\)/\1/g' file
sed -r 's|\\newline(</Text>)|\1|g' file
Would work just as well.
Add a comment
Are you just trying to get rid of the newlines before </Text>? That's just a simple substitution:
</Text>
gawk -vRS='\0' -vORS= '{gsub(/\n<\/Text>/,"</Text>")}1' file
I just found solution myself so thought to share with everyone.
sed ':a; N; $!ba; s|\\newline<\/Text>|</Text>|g' sample.text
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.