From owner-freebsd-questions@freebsd.org Tue Nov 7 18:20:49 2017 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 597BFE60D60 for ; Tue, 7 Nov 2017 18:20:49 +0000 (UTC) (envelope-from yuripv@gmx.com) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "mout.gmx.net", Issuer "TeleSec ServerPass DE-2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B38107D7A6 for ; Tue, 7 Nov 2017 18:20:48 +0000 (UTC) (envelope-from yuripv@gmx.com) Received: from thor.xvoid.org ([62.183.126.160]) by mail.gmx.com (mrgmx101 [212.227.17.174]) with ESMTPSA (Nemesis) id 0M3vCA-1f3HL91j4U-00rb9M; Tue, 07 Nov 2017 19:20:41 +0100 Subject: Re: sed - remove nul lines from file To: byrnejb@harte-lyne.ca Cc: freebsd-questions@freebsd.org References: <88a59a82-2902-9f63-0a94-bd23b910e7ad@gmx.com> <88b1870184a8810072fe503917cd86be.squirrel@webmail.harte-lyne.ca> From: Yuri Pankov Message-ID: Date: Tue, 7 Nov 2017 21:20:40 +0300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <88b1870184a8810072fe503917cd86be.squirrel@webmail.harte-lyne.ca> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:aaUR9bA5uqGwpCM2Wo/O3fAbEF0unpzOCW5MKD6Bqi9qo0LNQxf nbriOjSuCWS9uodkXrYY0Rgg/7mB2VIALRhw5TL7558EDEhX0HrYxRcMeaBBVM44oKAADZK UcFfD2nzamTcVGMCDj0fV+l+VKmt8Gi755e60+aJ4U+7xyk9HicL8KEEfhfzZGrfG2yhYJ5 wEeT2Xklc0T9pDzEFZjyQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:3xXRedZq1/Y=:wRUGB59Wiu0FlF5K7y0oiv bXZHo1rSJL3dDOoJ/Tf6pTi1IcbeWXs3qbO+eIcwk0f94wum/4dXrowRJH28i3AqS4mcFsx0z 8tOuKRQvSN3goLotHhbfKTwBmqXT7SW2x+tqX3CnIwc0FSzpASEksVoZtSt32x8IK78jwwbEt TQbLseDLXj9427gv4l2klIP8dcfFvnCUFdsj3weHBrIojuw/0gyOfxBZ6dEc9GmLCLa0DTIq8 qZ2gTi7N9mqngXg4jS/AgWYBxwFFFqGh8E0GuSRczXM+X4MR0s9aUy3hR3aJpjNrQ4jnPDvoN c50iRR79QDOgJya0GGaWFiHPvpHDXMtv7G6RprAkk4cD8KgyzEE6D8SvpX/cwT/oFPXrHsDCe Z31b5C6xbqF/jB3jE0l+RwQljwPwlWXxM7d57MJ2lTgLDnOT8wK4+a1LFJRVQR5AVcCqN5GTb puppHNeyQmDE7BBArli4bCkYfjEs2WBrRnIIzLG2JRWF1rM9NZzTs++nY3iHHld2otvENXAY4 TvNAggfpUnpd1D7VOZ7TWLg4F+gx4jDbGL7tTZx9Yyzq/XtZ91yCCRZQaHS9lzlb9sKDAQf+E 6xz7TBaj05f36dCNyU66kQdwy5VgERtk3muaAyNtFmZXu1YYQSo+sk0Zuz6qOPgTgfoJdcaLy UxueE2No2Zl1lmKB/AQWDtGcq1m4irAjkvVun4yqgLxqDL1sLewwHMnMBAGHRxiYgZGaQZE5i n3qidggPSlld/aPv+8vRYbPcSXr1JqE6auNrMnNXnbtxdLxE1nRFRgWVmpEu8E4w7f8HzTjOo JWHAIHmIgPE7rW/VoYIbmGsNtnispwsAtTsL3gaIe5WSuWl7MWHLMSuW4jHLHJn+cA0GYAA X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Nov 2017 18:20:49 -0000 On Tue, 7 Nov 2017 13:14:08 -0500, James B Byrne Via Freebsd-questions wrote: > > On Tue, November 7, 2017 13:03, Yuri Pankov wrote: > >> >> You want /d, not /g, to delete the *lines* which contain NUL symbols >> (that's what your subject line said). >> > > Sigh. Thank you. That works. However, it also deletes any line that > has even one NUL in it regardless of the presence of other non-nul > characters on the line. > > What I wish to accomplish is to delete only the lines that are > completely nul. I thought that this could be accomplished by > prefacing the match sting with the start of line anchor ^ and ending > it with the end of line anchor $ but this does not work as I expect. "[[.NUL.]]" is just a character specified by its collation name, so treat as any other ordinary character: sed -E '/^[[.NUL.]]+$/d' INFILE > OUTFILE Need extended regexp here for '+' to work.