#!/usr/bin/perl
use strict;
use warnings;
my $logfile = $ARGV[0];
open (LOG, $logfile) or die "can't open $logfile: " . $!;
while (my $line = <LOG>) {
chomp($line);
my @cols = split /\s+/, $line;
my $cpufile = shift @cols;
open (OUT, ">> " . $file") or die "can't open $cpufile: " . $!;
print OUT join " ", @cols;
close OUT;
}
Benjamin Foote
http://pdxstump.com - a search engine and news aggregator for Portland
http://bnf.net - Linux and Java Consulting
[email protected]
503-313-5379
@pdxstump on twitter
On Mon, Mar 5, 2012 at 10:26 AM, Pete Lancashire <[email protected]>wrote:
> my brain this morning is blocked on this one
>
> I have a data file
>
> cpu01 value value value
> cpu02 value value value
> cpu03 value value value
> ...
> cpu01 value value value
> cpu02 value value value
> cpu03 value value value
> ...
> cpu01 value value value
> cpu02 value value value
> cpu03 value value value
> ...
>
> column 1 can be cpu\d+ and cpu_all
>
> I want to open files for writing, one for each unique value in the first
> column.
> so that if the value f the data in the first column is "cpu01" then
> write to the file
> with the FH of $cpu01
>
> This has to be simple ...
>
> -pete
> _______________________________________________
> PLUG mailing list
> [email protected]
> http://lists.pdxlinux.org/mailman/listinfo/plug
>
_______________________________________________
PLUG mailing list
[email protected]
http://lists.pdxlinux.org/mailman/listinfo/plug