On Wed, 3 Aug 2005, Mike Branda wrote:
> On Wed, 2005-08-03 at 17:13 -0400, Eben King wrote:
> > On Wed, 3 Aug 2005, Mike Branda wrote:
> >
> > > #!/bin/bash
> > >
> > > home="/home/wws1"
> > > logdir="$home/cumulativelog"
> > > file1="access.log.*.gz"
> >
> > I hope you aren't relying on some program's behavior of "when presented with
> > multiple files e.g. 'access.jan.log.gz access.feb.log.gz access.mar.log.gz'
> > only deal with the first one" (and the fact that $file1 isn't in ""),
> > because that'll break as soon as somebody touch(1)es a previous month's
> > file. I like Bill Glidden's idea of using date(1).
>
> I use date when the file is created. And actually, I want it to deal with
> all the files. That's the point and problem. It worked fine until 2 days
> ago but now more than one file exists.
Yeah, what gets run is something like
file1="access.log.jul.gz access.log.jun.gz"
No error there. But later on when you call
(gunzip -c $logdir/$file1 && cat $logdir/$file2) | $commanda
what gets run is
(gunzip -c /home/wws1/cumulativelog/access.log.jul.gz access.log.jun.gz && ...
So that won't work. Oh, and $home is defined (contrary to my comment), but
IMO the similarity of "home" to "HOME" invites confusion. Maybe call it
"wws_home" instead?
> I was expecting the file1="access.log.*.gz" to give me output of all the
> gzipped per month files. It choked this month because there's more than
> one. How do I get it to decompress/read them all?
for file in "$logdir"/access.log.*.gz ; do
# do stuff with $file
done
They'll be dealt with in dictionary (not chronological) order. Is that OK?
> The error is:
>
> ./createReports.sh: [: /home/wws1/cumulativelog/access.log.2005-08-01.gz: binary operator expected
Hmm, doesn't say what line. That would help.
-- The powers in charge keep us in a continuous stampede of patriotic fervor with the cry of national emergency. Always there has been some terrible evil to gobble us up if we did not furnish the exorbitant sums demanded. Yet, in retro- spect, these disasters seem never to have been quite real. -- Gen. D. MacArthur----------------------------------------------------------------------- This list is provided as an unmoderated internet service by Networked Knowledge Systems (NKS). Views and opinions expressed in messages posted are those of the author and do not necessarily reflect the official policy or position of NKS or any of its employees.
This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 19:41:33 EDT