reinplace - how to remove a new line char

Darren Weber dweber at macports.org
Fri May 29 15:11:16 PDT 2009


An example of how to remove a line with some search text in it.  Assume
tmp.txt contains:

# BEGIN (not in file)
abc
def
# END (not in file)

reinplace {$!N;s|^.*abc.*\\n||g} tmp.txt

If you need to include variables -- escape, escape, escape!

set abcVar abc
reinplace "\$!N;s|^.*${abcVar}.*\\n||g"

The result should be:

# BEGIN (not in file)
def
# END (not in file)


Regards,
Darren

PS, Thanks to google refs for some relevant sed tips, e.g.:
http://www.computing.net/answers/unix/remove-all-n-in-sed/7399.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-dev/attachments/20090529/fc8c2d15/attachment.html>


More information about the macports-dev mailing list