[plug] Using sed to remove \n from a text file.

The Thought Assassin assassin at penguincare.com.au
Thu Jul 11 14:35:56 WST 2002


On Thu, 11 Jul 2002, Buddrige, David wrote:
> What I am wanting to do is use a sed script to remove any occurence of "-\n"
> and replace it with no characters at all.

This isn't really the sort of thing sed is strongest at - sed likes to
work on one line at a time if possible - but it can be done fairly easily:
sed '/-$/N; s/-\n//' filename

If a line contains more than one dash, that won't work, you'll need to
branch back to the beginning of the script. I'll get back to you in 5. :)

-Greg



More information about the plug mailing list