* wildcard in.sh script
m.seaman at infracaninophile.co.uk
Tue Jun 15 09:00:55 UTC 2010
-----BEGIN PGP SIGNED MESSAGE-----
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.
Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard
PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate
JID: matthew at 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/
-----END PGP SIGNATURE-----
More information about the freebsd-questions