Answer by steeldriver for How to use sed to remove newlines above and below a...
Rather then treating the problem as a multi-line substitution, you might consider using the non-streaming ed editor instead, which provides a join command and supports relative addresses. Ex. given$...
View ArticleAnswer by Raffa for How to use sed to remove newlines above and below a string?
A backslash is used in ERE's to escape (strip special meaning from) characters in order to match them literally ... However, in BRE's, it also adds a special meaning to some characters.So, it has a...
View ArticleAnswer by BeastOfCaerbannog for How to use sed to remove newlines above and...
To be able to use \n as newline character in a sed command you have to use the -z flag, which separates the lines by NUL characters instead of newlines (\n). So the command you can use is the...
View ArticleHow to use sed to remove newlines above and below a string?
I'd like to change all occurrences of \ntoken1\n and \ntoken2\n to token1 and token2 in a file).I thought this would do it:${NNs/\ntoken1\n/token1/s/\ntoken2\n/token2/}but it does not.Thanks in advance...
View ArticleAnswer by Ed Morton for How to use sed to remove newlines above and below a...
Using any awk and only storing 1 line at a time in memory:$ awk ' /^(token1|token2)$/ { ors=ORS="" } { printf "%s%s", ors, $0; ors=ORS; ORS=RS } END { printf "%s", ors }'...
View Article
More Pages to Explore .....