From owner-freebsd-questions@freebsd.org Tue Nov 7 18:28:36 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 6B7A0E6110E for ; Tue, 7 Nov 2017 18:28:36 +0000 (UTC) (envelope-from yuripv@gmx.com) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) (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 C68F37E2D1 for ; Tue, 7 Nov 2017 18:28:35 +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 0Ls8Qd-1fF3qC1GZz-013w8J; Tue, 07 Nov 2017 19:28:23 +0100 Subject: Re: sed - remove nul lines from file From: Yuri Pankov To: byrnejb@harte-lyne.ca Cc: freebsd-questions@freebsd.org References: <88a59a82-2902-9f63-0a94-bd23b910e7ad@gmx.com> <88b1870184a8810072fe503917cd86be.squirrel@webmail.harte-lyne.ca> Message-ID: <656b08b1-b79d-8e7e-27ec-e39d883f2355@gmx.com> Date: Tue, 7 Nov 2017 21:28:22 +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: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:QBVnVml3VSFBne6ScvCv2sbCHyjlM/wZASnvWFH5pqdAmtQxFsm /qLYqElwFvo9HAYaqgdKJ7ggDPrx4pAcI6OXUB1+s1bjS9x/pAHd/n0HueJRzWJz50vGgpr UiF11QtQNEEB4EVtpkpw7ZCyPZHN+muA4vPrkCmL/M1e020umZJb9PaRX4zWz+CrqF597jI xxzlZ7Rxp/jpQqqfAKcKg== X-UI-Out-Filterresults: notjunk:1;V01:K0:T8mDsQSbXJs=:5RDrjNolZWW6Dm51UK0F2W 6dDvI76fxKnx8v0CYj+jk/+tasM74i6Bo54mDT6BdCl7HUSenrjeIDqrLC3x4VUf6BJV/7zHU vHC7/fEheT+AjTOhakZVKRVuxNsQGBy3BExurIbEvhZSjm70EMtdpMRwfT51Gr7zO2bEZZYBI KTEGH5CVQ8V1FtN9/02eFzDK8wWBNblOJ0bCGM7MsO5qdlnC8dFlow2hHl/N2Q0XCEGYEbLim 1+8YEgEVI3gPI/NVIQc7HDnoh7bag/euCeHj5b8Oxvb3sttNjm5Aznm8w0n0Y0upfaTmfIOZv nxNYAkXYNX0wtOQjxviEZS+3Z4jjGuSzEVhaRzCUFgO2EsjYFomSg182oj0OjLMY/QhWb71of W3ejI+4CT1ENXgu4vM9GZiV2QQnlgBsLbJIig3ems+xkMEj8Sn5prGQdxJ4QMu+45bOYmK+6w +rkOzcwQVf3CuuqMSYKhund6hZc+CQGIOHpbe124Sg/ZmR/P1PYMT/5froPCxqgNNNuUBWVDW hpY+1w7pr0Gjpn0wvlcswcPyma7W5eJAZ56TkGVUfNnUGYXODvWLAxSX0Li865D928gEO8Kg2 GZL55yTdQnE0lV7jaPQzsYnxFMHptga8sol9nTM4DMxkf1mj3VL05B/iMNdqkrkCkQCCALXoI vDsQua7DJlrEEp99HSWz5Td4Ht2rlASFIsNeJQwe4RrjKQN4CuM06pkHMNCorkDwIeHk860Rl hRywvX572s80pzZF3HKIq1gv7tbSYe1KR1I1rcsZtLOQbW9GN5XhQqT8n5qALDYxo2Z/Fyvmy d6AD0A/bFweHcqL3doPzZpFGAFPN5S4VXVIvldM7cKehdN5QdOPVknOvR8Qw7b9vDComMFq 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:28:36 -0000 On Tue, 7 Nov 2017 21:20:40 +0300, Yuri Pankov wrote: > 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. Or, after looking at re_format(7), it could be written using BREs, your choice :-) sed '/^[[.NUL.]]\{1,\}$/d'