Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 07 Nov 2002 13:23:13 -0800
From:      "Paul A. Scott" <pscott@skycoast.us>
To:        Miguel Mendez <flynn@energyhq.homeip.net>, Mathew Kanner <mat@cnd.mcgill.ca>
Cc:        <freebsd-questions@freebsd.org>
Subject:   Re: stupid sed question
Message-ID:  <B9F019C1.F3A9%pscott@skycoast.us>
In-Reply-To: <20021107221324.6d9f92bd.flynn@energyhq.homeip.net>

next in thread | previous in thread | raw e-mail | index | archive | help
> How about echo abc | tr 'b' '\n' ?

tr substitutes characters only, while sed can work on arbitrary strings and
patterns. My guess is that the example was a simplified expression of a more
general requirement, in which case sed is appropriate and therefore,

echo aaabbbccc | sed -e 's,bbb,\
,'

will yield

aaa
ccc

as expected, while tr would give

aaa


ccc

which is almost certainly not wanted.

(Reminder: you need \\ if typing directly on the command line, or a single \
if entered in a script.)

Paul A. Scott
mailto:pscott@skycoast.us
http://skycoast.us/pscott/


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?B9F019C1.F3A9%pscott>