Re: eval and wildcard expansion problem
bung_ho_at_hotmail.com
Date: 06/23/05
- Next message: Chris F.A. Johnson: "Re: eval and wildcard expansion problem"
- Previous message: Chris F.A. Johnson: "Re: eval and wildcard expansion problem"
- In reply to: Chris F.A. Johnson: "Re: eval and wildcard expansion problem"
- Next in thread: Chris F.A. Johnson: "Re: eval and wildcard expansion problem"
- Reply: Chris F.A. Johnson: "Re: eval and wildcard expansion problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 23 Jun 2005 13:30:44 -0700
Chris F.A. Johnson wrote:
> On 2005-06-23, bung_ho@hotmail.com wrote:
> > ok, so in a (bash) script i'm trying to do the following:
> >
> > ---------
> > FINDLOGINLOGFILES="find $DIR/logs -name login*.log"
> >
> > # ... other stuff ...
> >
> > LOGINLOGINFILES=`$FINDLOGINLOGFILES`
> > ---------
> >
> > It's supposed to do what it looks like--I want to store the command
> > (with $DIR being substituted) in a variable, and then later execute
> > that command and store the results in another variable.
> >
> > This works for the most part until I encountered a situation when there
> > happened to be a file that satisfied the "login*.log" part in the PWD
> > when the script was run (not in $DIR). I thought that the double
> > quotes around the whole command should have protected the wildcard from
> > expansion by the shell, but it didn't, so when it came to executing the
> > command, it actually tried to do
> >
> > find mydir/logs -name login1.log login2.log
> >
> > which of course isn't what i want. i tried to protect it more by
> > changing the line to use single quotes around the login*.log, or to
> > backslash the *, but then the find command wouldn't actually find the
> > files in $DIR.
>
> When you do LOGINLOGINFILES=`$FINDLOGINLOGFILES`, there are no
> quotes.
>
> What you need is:
>
> FINDLOGINLOGFILES="find $DIR/logs -name 'login*.log'"
>
> --
> Chris F.A. Johnson <http://cfaj.freeshell.org>
> ==================================================================
> Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress
> <http://www.torfree.net/~chris/books/cfaj/ssr.html>
Thanks for the reply. I did try that with the single quotes, also
tried escaping the *, but then when executed, the find command didn't
find the files in $DIR. I'm not really sure why, because when I try it
at the command line (i.e., with the single quotes), it does find them.
But in the script, it doesn't find them. Any idea what I might be
doing wrong?
- Next message: Chris F.A. Johnson: "Re: eval and wildcard expansion problem"
- Previous message: Chris F.A. Johnson: "Re: eval and wildcard expansion problem"
- In reply to: Chris F.A. Johnson: "Re: eval and wildcard expansion problem"
- Next in thread: Chris F.A. Johnson: "Re: eval and wildcard expansion problem"
- Reply: Chris F.A. Johnson: "Re: eval and wildcard expansion problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|