[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: say if grep can find non-ascii

From: Julian Foad
Subject: Re: say if grep can find non-ascii
Date: Mon, 06 Mar 2006 23:59:45 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050511

Dan Jacobson wrote:
The grep manual page should say how to do
$ perl -nwe 'print if /[^[:ascii:]]/'
but with grep. Or say if there's no way.

I don't think the Grep manual should say explicitly how to do that particular thing. The Grep manual should (and does) describe exactly what Grep can do and how to make it do what it can do, and it may give some examples. Is there any particular reason you feel it should describe how to do the equivalent of your particular Perl command?

As far as I can tell, you want to find each line that contains a non-ASCII character, except that I'm not sure what the definition of "ASCII" is in this case, nor how the behaviour of this Perl command is affected by locale.

I assume you've seen in Grep's manual (and I'll assume you're using Grep v2.5.1) that it supports a set of character classes such as "[:alnum:]" but not "[:ascii:]".

Does the following command do what you want?

  grep '[ -~]'

- Julian

reply via email to

[Prev in Thread] Current Thread [Next in Thread]