[Gllug] Friday bash or maybe Perl question

- Tethys tethys at gmail.com
Fri Oct 6 10:52:48 UTC 2006


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

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




More information about the GLLUG mailing list