bin/160745: sed(1) appends '\n' at the end of binary data (unlike gsed(1))

Wojciech A. Koszek wkoszek at
Thu Sep 15 01:50:06 UTC 2011

>Number:         160745
>Category:       bin
>Synopsis:       sed(1) appends '\n' at the end of binary data (unlike gsed(1))
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Sep 15 01:50:05 UTC 2011
>Originator:     Wojciech A. Koszek
>Release:        8.2-STABLE
FreeBSD Project
FreeBSD  8.2-STABLE FreeBSD 8.2-STABLE #0: Tue Sep 13 21:31:11 CET 2011     root@:/usr/src/sys/i386/compile/GENERIC  i386

File has ASCII data followed by binary data.

ASCII data contains lines. Binary data contains 0's and follows.

I use sed(1) to delete lines and present me the rest of the content in
untouched form. In other words: I want to get binary data streamed
throught sed(1) without modification.

Currently sed(1) appends '\n' at the end of such data.

gsed(1) works as expected.

While gsed(1) just pipes binary data without a problem, we
pipe data, but append '\n' at the end.
Install ports/textproc/gsed for comparison.


Script below.


echo 1 > data
echo 2 >> data
echo 3 >> data
dd if=/dev/zero bs=1m count=1 >> data
echo "========== WE ========="
cat data | sed '1,3 d' | hexdump -c | tail -5
echo "========== GNU ========"
cat data | gsed '1,3 d' | hexdump -c | tail -5



More information about the freebsd-bugs mailing list