* wildcard in.sh script

Aiza aiza21 at comclark.com
Tue Jun 15 09:06:16 UTC 2010

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.

Here is the code

   prefix_name2=`echo -n "${prefix_name1}" | sed 's/*.*$//'`
   echo "prefix_name1 = ${prefix_name1}"
   echo "prefix_name2 = ${prefix_name2}"

   if [ ${prefix_name1} -nq ${prefix_name2} ]; then
   echo "prefix_name2 = ${prefix_name2}"
exerr "hard stop"

Here is the test and out put
# >admin cell*
admin: No match.

More information about the freebsd-questions mailing list