Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Jun 2010 10:00:42 +0100
From:      Matthew Seaman <m.seaman@infracaninophile.co.uk>
To:        Aiza <aiza21@comclark.com>
Cc:        "questions@freebsd.org" <questions@freebsd.org>
Subject:   Re: * wildcard in.sh script
Message-ID:  <4C17413A.2000807@infracaninophile.co.uk>
In-Reply-To: <4C173909.1050101@comclark.com>
References:  <4C173909.1050101@comclark.com>

next in thread | previous in thread | raw e-mail | index | archive | help
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 15/06/2010 09:25:45, Aiza wrote:
> I have a directory with files in it. The first 3 letters of the file
> names is the group prefix. I'm trying to write a script to accept the 3
> letter of the group followed by a * to mean its a prefix lookup. But
> when I run it I get a message "NO match" that is not issued by the
> script. Its like * is not allowed as input.
> 
> Looking for sample .sh code for handling this standard type of lookup or
> some online tutorial that has sample code for bourne shell programming.

It would be helpful if you could show us some code, so we can tell
exactly what you're trying to do.

It sounds like your problem is you'ld like to supply a globbing pattern
as an argument to your script, and then apply it within the script.  So
you'ld like to call the script something like this:

   $ myscript.sh -p globpattern filename....

The trick there would be to enclose globpattern in "quote marks", which
will cause it to be passed literally into the script, rather than your
interactive shell attempting to expand the pattern before starting the
script and passing the arguments to it.  (That's a classic way of
getting a "No match" error message which seems to come from a program
that couldn't have generated it)

Note that it's not just the shell that can do globbing expansions --
find(1), pkg_info(1) are two examples I can think of immediately.  These
glob-pattern command line arguments similarly need quoting to protect
them from the shell.

	Cheers,

	Matthew

- -- 
Dr Matthew J Seaman MA, D.Phil.                   7 Priory Courtyard
                                                  Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey     Ramsgate
JID: matthew@infracaninophile.co.uk               Kent, CT11 9PW
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkwXQToACgkQ8Mjk52CukIxOrACggdei0bi8k13jyOg3tGQXyKp3
yFgAnjPJHivqt4VqM84UnGWqpFA/QQnR
=FwzT
-----END PGP SIGNATURE-----



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4C17413A.2000807>