Try this:

   #!/usr/bin/ksh
   for DIRECTORY in "$@"; do
      echo $DIRECTORY
      ls $DIRECTORY
   done

When called, such as:    list.ksh disk*   your shell will expand the * to
cover disk1, disk2, etc. These are then all assigned as the value of $@.
This can be done w/ a while loop, but the for loop keeps the parameters in
their order so $1 will remain disk1, $2 will remain disk2, etc (while loops
shift them off the end).  Plus I'm just happier with for loops.  I put the
"echo $DIRECTORY" line in just so that when you look at the output you know
what directory is being shown.  Remember, with the joys of pipes and
redirection you can use the ls command, strip off unwanted fields, and send
it to your command to generate thumbnails, listings, etc. Hope this helps.

-Larry

> -----Original Message-----
> From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, January 24, 2001 8:09 AM
> To:   [EMAIL PROTECTED]
> Subject:      Re: bash shell scripting questions
> 
> 
> 
> >I have a pictures directory.  in that directory are
> >three more called disk1, disk2, and disk3.
> >
> >What the script is *supposed* to do is "ls $1*.jpg"
> >but when I use disk* as the variable, all I get back
> >is the contents of disk1.
> 
> 
> Let's say that you've named your script tomScript.
> From your description it sounds like you're invoking
> it thus:
> 
>    tomScript disk*
> 
> and then expecting to see the string "disk*" as the
> first argument.  But recall that the shell will first
> expand disk* to
> 
>    disk1 disk2 disk3
> 
> before launching your script and passing that
> expanded list as its aruments, so your script
> will see its $1 as disk1, just as you report.
> You can illustrate this for yourself (for
> debugging purposes) by putting a line like
> this somewhere in your script:
> 
>    echo Args are: $*
> 
> For quick and dirty scripts it's probably more
> trouble than it's worth to try to make them
> able to accept and then expand filename RE's
> (Regular Expressions, ie wildcards) specified
> on the command line - much simpler for them
> to expect verbatim lists of files as arguments,
> with the (invoking) shell having already done
> all that dirty work...
> 
> 
> **********************************************************
> To unsubscribe from this list, send mail to
> [EMAIL PROTECTED] with the following text in the
> *body* (*not* the subject line) of the letter:
> unsubscribe gnhlug
> **********************************************************

**********************************************************
To unsubscribe from this list, send mail to
[EMAIL PROTECTED] with the following text in the
*body* (*not* the subject line) of the letter:
unsubscribe gnhlug
**********************************************************

Reply via email to