GNU bug report logs - #35195
sed '/^$/d' does not delete empty lines

Previous Next

Package: sed;

Reported by: Chin Huat Tan <tch1126 <at> gmail.com>

Date: Mon, 8 Apr 2019 14:19:03 UTC

Severity: normal

Tags: notabug

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 35195 in the body.
You can then email your comments to 35195 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-sed <at> gnu.org:
bug#35195; Package sed. (Mon, 08 Apr 2019 14:19:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Chin Huat Tan <tch1126 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-sed <at> gnu.org. (Mon, 08 Apr 2019 14:19:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Chin Huat Tan <tch1126 <at> gmail.com>
To: bug-sed <at> gnu.org
Subject: sed '/^$/d' does not delete empty lines
Date: Mon, 8 Apr 2019 20:02:36 +0800
[Message part 1 (text/plain, inline)]
sed '/^$/d' does not delete empty lines on the attached file.

-- 
Tan Chin Huat
HP : 010 225 1918
eMail : tch1126 <at> gmail.com
[Message part 2 (text/html, inline)]
[LLK-01.txt (text/plain, attachment)]

Information forwarded to bug-sed <at> gnu.org:
bug#35195; Package sed. (Mon, 08 Apr 2019 22:09:02 GMT) Full text and rfc822 format available.

Message #8 received at 35195 <at> debbugs.gnu.org (full text, mbox):

From: Assaf Gordon <assafgordon <at> gmail.com>
To: Chin Huat Tan <tch1126 <at> gmail.com>, 35195 <at> debbugs.gnu.org
Subject: Re: bug#35195: sed '/^$/d' does not delete empty lines
Date: Mon, 8 Apr 2019 16:07:53 -0600
tags 35195 notabug
close 35195
stop

Hello,

On 2019-04-08 6:02 a.m., Chin Huat Tan wrote:
> sed '/^$/d' does not delete empty lines on the attached file.

The attached file contains windows-style line-ends (\r\n , aka 
carriage-return + line feed):

   $ head -n 3 LLK-01.txt | od -c -An
    h   t   t   p   s   :   /   /   w   w   w   .   y   o   u   t
    u   b   e   .   c   o   m   /   w   a   t   c   h   ?   v   =
    t   w   x   q   l   U   K   d   Y   q   g  \r  \n  \r  \n   h
    t   t   p   s   :   /   /   w   w   w   .   y   o   u   t   u
    b   e   .   c   o   m   /   w   a   t   c   h   ?   v   =   L
    e   I   h   O   u   T   N   v   M   8  \r  \n

Therefor lines are not really empty (from unix POV),
as they contain a '\r' character.

You can use "dos2unix" utility to convert the file to unix-style.
    dos2unix LLK-01.txt
    sed '/^$/d' LLK-01.txt

You can use 'tr' to delete the '\r' characters:
    cat LLK-01.txt | tr -d '\r' | sed '/^$/d'

Or you can instruct sed to accept these characters as well:
    sed '/^\r*$/d' LLK-01.txt


As such I'm closing this as "not a bug", but discussion can continue by
replying to this thread.

regards,
 - assaf





Added tag(s) notabug. Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 08 Apr 2019 22:09:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 35195 <at> debbugs.gnu.org and Chin Huat Tan <tch1126 <at> gmail.com> Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 08 Apr 2019 22:09:04 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 07 May 2019 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 356 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.