[Gllug] Friday bash or maybe Perl question

Simon Perry gllug at si-designs.co.uk
Fri Oct 6 12:05:23 UTC 2006


- Tethys wrote:
> On 10/6/06, Simon Perry <gllug at si-designs.co.uk> wrote:
> 
>> I have a directory with some files named in the format log-APR-2006.gz
>>
>> For each log file I need to expand the file, split the lines that
>> contain "aff_img" into aff-MMM-YYYY and the rest of the lines into
>> new-MMM-YYYY.
> 
> #!/bin/sh
> 
> ls -1 "${1:-.}" | while read file
> do
>    stem="${file%.gz}"
>    gzip -dc "$file" | grep aff_img > "${stem//log/aff}"
>    gzip -dc "$file" | grep -v aff_img > "${stem//log/new}"
> done

Many thanks Tet that was just the ticket.

Simon

-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list