help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] something about "find"


From: Greg Wooledge
Subject: Re: [Help-bash] something about "find"
Date: Fri, 30 Dec 2011 08:18:47 -0500
User-agent: Mutt/1.4.2.3i

On Thu, Dec 29, 2011 at 10:41:53PM +0800, lina wrote:
> I tried
> 
> $ grep -e "7.9" -e "2.4" -e "4.2" -e "12.2" */*
> 
> ...
> lots of nonsense results out like
> ...
> s100a9/s100a9.log:Package: natmove 2009/04/20 v1.1 Automatic citation 
> moving with natbib

grep knows 3 different kinds of patterns: Basic Regular Expressions (BRE),
Extended Regular Expressions (ERE), and plain strings.  By default, grep
uses BRE, and in BRE syntax, the "." is a single-character wildcard; that
is, it matches any single character in the input.

In this case, the grep for BRE pattern "4.2" matched the "4/2" in the
datestamp.

If you want grep to match only literal periods, you must either tell grep
to use plain strings (with the -F option), or write an appropriate BRE
pattern ('4\.2' and so on).  The -F option would be much cleaner here.



reply via email to

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