grr @ grep syntax

Richard Sharpe rsharpe at richardsharpe.com
Thu Dec 5 11:57:28 CST 2002


On Thu, 5 Dec 2002, David Lloyd wrote:

> 
> Richard,
> 
> > Except that you really want to escape the * incase there are any files
> > that match in the current directory. Also, -print is the default under
> > Linux, but not under other versions of UNIX. Another point is that you
> > need to escape the * for shells other than Bash.
> 
> In my experience:
> 
> % find -name *.foo
> 
> ..generally always needs escaping :-)

However, you need to understand why it does or doesn't.

In the case of bash, if it does not find anything that matches the 
wildcard spec you have supplied, it passes that string through to the 
program, whereas other shells, like ksh or sh, will print 'no match' if 
they don't find a match to a wild-card spec, and will not execute the 
command.

So, 'find -name *.foo' will work OK if there is nothing that matches in 
the current directory, but will behave in strange ways if there is 
something matching in the current directory.

So, I was telling people what they should use, and hinting at why.

Regards
-----
Richard Sharpe, rsharpe[at]ns.aus.com, rsharpe[at]samba.org, 
sharpe[at]ethereal.com, http://www.richardsharpe.com

-- 
LinuxSA WWW: http://www.linuxsa.org.au/ IRC: #linuxsa on irc.openprojects.net
To unsubscribe from the LinuxSA list:
  mail linuxsa-request at linuxsa.org.au with "unsubscribe" as the subject



More information about the linuxsa mailing list