[plug] Using sed to remove \n from a text file.
Leon Brooks
leon at brooks.fdns.net
Thu Jul 11 14:53:43 WST 2002
On Thu, 11 Jul 2002 14:44, The Thought Assassin wrote:
> sed ':a; /-$/N; s/-\n//; ta' filename
> and now a word of explanation:
> sed edits one line at a time. On each line, it runs through the list of
> four semicolon-seperated commands, then goes to the next line.
> Command 1: ':a' This is a tag for branching to.
> Command 2: '/-$/N' This invokes the N command on lines ending with a -.
> The N command appends the next line into the buffer.
> Command 3: 's/-\n//; Replaces '-\n' by '', now they're on the same line.
> Command 4: 'ta' Branches back to the 'a' tag, _if_ the 's' succeeded.
That line about `knows sed very well, which is why he uses PERL' comes to
mind. (-:
Cheers; Leon
More information about the plug
mailing list