Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <42DD2E12.458D22A1@dessent.net> Date: Tue, 19 Jul 2005 09:45:06 -0700 From: Brian Dessent MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: OT: grep for \x00 = NUL References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Report: -5.9/5.0 ---- Start SpamAssassin results * -3.3 ALL_TRUSTED Did not pass through any untrusted hosts * -2.6 BAYES_00 BODY: Bayesian spam probability is 0 to 1% * [score: 0.0000] * 0.0 AWL AWL: From: address is in the auto white-list ---- End SpamAssassin results X-IsSubscribed: yes Reply-To: cygwin AT cygwin DOT com fergus wrote: > grep $'\x0d' # e.g. equivalent to grep "^M" Using that method you're passing the literal character to grep through a bash quoting mechanism. You can't pass a literal NULL as part of a command line because argv[] consists of NULL-delimited strings, as do most C string functions. Why not just tell grep to look for a NULL rather than trying to feed it an actual literal NULL character? $ grep -P '\000' In pcre regexps you can use \nnn to match any character represented by octal nnn. This would work for any character, and it doesn't rely on a bash-specific shell feature. But it does rely on grep supporting -P for pcre, which is not universal. If that cannot be relied on then you can use $ perl -ne 'print if m/\000/' or $ awk '/\000/ { print }' Brian -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/