[OT] sed question

Bill Campbell freebsd at celestial.com
Sun Mar 14 16:46:25 PST 2004


On Sun, Mar 14, 2004, 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.

I thought it was the other way around, that the gnu version of
sed accepts the standard ``C'' escape sequences, but the FreeBSD
version doesn't.  I always use the gnu tools configured with the
program-prefix='g' option, and referenced as ``gsed'' rather than
depending the the native ``sed'' doing what I expect.

Bill
--
INTERNET:   bill at Celestial.COM  Bill Campbell; Celestial Software LLC
UUCP:               camco!bill  PO Box 820; 6641 E. Mercer Way
FAX:            (206) 232-9186  Mercer Island, WA 98040-0820; (206) 236-1676
URL: http://www.celestial.com/

``Never chastise a Windows user...just smile at them kindly as you would a
disadvantaged child.'' WBM


More information about the freebsd-questions mailing list