why is this script failing?
David Kelly
dkelly at hiwaay.net
Tue Jul 15 19:02:30 UTC 2008
On Tue, Jul 15, 2008 at 11:35:00AM -0700, Gary Kline wrote:
> On Tue, Jul 15, 2008 at 07:37:02AM +0200, Wojciech Puchar wrote:
> > >
> > > why is this script not finding them?
> > >
> > >
> > >wav=/tmp/kde-kline/\*wav\*
> >
> > why you put \ before *
>
> to allow the shell to catch various formsof strings with "wav"
> embedded.
I questioned that escape earlier.
Without the \ escape the variable ${wav} will contain all the files
matching the pattern. But with the escape it will literally be
"/tmp/kde-kline/*wav*". Wildcard expansion doesn't occur until later
when Gary does something like this:
rm ${wav}
which is processed as if he had just now typed:
rm /tmp/kde-kline/*wav*
while without the escape it might appear like this:
rm /tmp/kde-kline/file1.wav /tmp/kde-kline/file2.wav
Is probably best to postpone wildcard expansion until the last moment
because if any of the filenames contain spaces the space will probably
cause a break between arguments. The first time the wildcard expands to
a filename with a space the space will be escaped. But the second time
you use it that escape is lost. So its best to expand it in the place
its needed.
--
David Kelly N4HHE, dkelly at HiWAAY.net
========================================================================
Whom computers would destroy, they must first drive mad.
More information about the freebsd-questions
mailing list