[OT] sed question
Rob Ellis
rob at web.ca
Sun Mar 14 16:18:35 PST 2004
On Sun, Mar 14, 2004 at 04:50:40PM -0700, Warren Block wrote:
> On Sun, 14 Mar 2004, Steven N. Fettig wrote:
>
> > I can't figure out what the newline character is... I've tried \n \r &\,
> > etc. with no avail. I run the following:
> >
> > sed 's/[ ]/\n/g' my_test_text_document.txt
>
> >From the sed man page:
>
> "2. The escape sequence \n matches a newline character embedded in
> the pattern space. You can't, however, use a literal newline
> character in an address or in the substitute command."
>
> I think this is a BSD thing, and sed on other systems does handle \n and
> other literals in substitutions. It's annoying enough that I just use
> Perl instead.
>
This works with sed in /bin/sh and ksh:
sed -e 's/ */\
/g' my_test_text_document.txt
I.e., escape an actual newline. Two spaces before the '*'.
It doesn't work in csh. Don't know why...
- Rob
More information about the freebsd-questions
mailing list