From owner-freebsd-questions@freebsd.org Fri Nov 1 09:22:18 2019 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AECF41AE3B6 for ; Fri, 1 Nov 2019 09:22:18 +0000 (UTC) (envelope-from mail@ozzmosis.com) Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 474GtK1nLcz3ybP for ; Fri, 1 Nov 2019 09:22:17 +0000 (UTC) (envelope-from mail@ozzmosis.com) X-Originating-IP: 167.179.139.56 Received: from blizzard.ozzmosis.com (167-179-139-56.a7b38b.mel.nbn.aussiebb.net [167.179.139.56]) (Authenticated sender: ozzmosis@ozzmosis.com) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 291D520008; Fri, 1 Nov 2019 09:22:13 +0000 (UTC) Received: by blizzard.ozzmosis.com (Postfix, from userid 1001) id 435BA73505; Fri, 1 Nov 2019 20:22:06 +1100 (AEDT) Date: Fri, 1 Nov 2019 20:22:06 +1100 From: andrew clarke To: Victor Sudakov Cc: freebsd-questions@freebsd.org Subject: Re: grep for ascii nul Message-ID: <20191101092206.rvydwz5ezdfbsqhq@ozzmosis.com> References: <20191101024817.GA60134@admin.sibptus.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191101024817.GA60134@admin.sibptus.ru> User-Agent: NeoMutt/20180716 X-Rspamd-Queue-Id: 474GtK1nLcz3ybP X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of mail@ozzmosis.com designates 217.70.183.200 as permitted sender) smtp.mailfrom=mail@ozzmosis.com X-Spamd-Result: default: False [-3.42 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; HAS_XOIP(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:217.70.183.192/28]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[ozzmosis.com]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; IP_SCORE(-1.02)[ip: (-2.21), ipnet: 217.70.176.0/20(-1.60), asn: 29169(-1.28), country: FR(-0.00)]; RCVD_IN_DNSWL_LOW(-0.10)[200.183.70.217.list.dnswl.org : 127.0.5.1]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:29169, ipnet:217.70.176.0/20, country:FR]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Nov 2019 09:22:18 -0000 On Fri 2019-11-01 09:48:17 UTC+0700, Victor Sudakov (vas@sibptus.ru) wrote: > Dear Colleagues, > > How can I print the names of files containing ascii nul (\x0)? The > FreeBSD "grep -l" does not seem to be able to do it. > > NB I don't need to delete the nul character with sed or tr, just need to > find files containing it. I don't believe FreeBSD (or Linux, Windows or even DOS) allows filenames containing a null. Any regular C program that treats filenames as a null-terminated string would correctly stop iterating over the string at the first null. Consequently two files named "Hello" and another named "Hello\0world" would be seen as identical, leading to unpredictable results.