[wplug] awk help [RESOLVED] scripts

chris.romano at verizon.net chris.romano at verizon.net
Sun Aug 29 10:38:26 EDT 2004


Here are the scripts, just incase anyone needs them in the future.
ptest.pl - used to format the file. Change the fs from "," to ":"

#!/usr/bin/perl

open(FILE,"$ARGV[0]") || die "Could not read $ARGV[0]";

while ( <FILE> ) {

@line = split(/\"/,$_); # first split the line on quotes
$quote = 0; # set a toggle for whether we're in a quote section or not

foreach $qpart ( @line ) {

if ( $quote ) {
# if we're in a quote section just print it
print "$qpart:";
$quote = 0;
} else {
# if we're not, split on commas and print the parts
@parts = split(/\,/,$qpart);
foreach $part ( @parts ) {
print "$part:";
}
$quote = 1;
}

}

}

close FILE;

awk.sh - used to pull certain fields from the file.

#!/bin/bash

`cat $1 | awk 'BEGIN{FS=":"}{print "NULL;"$14";"$13";"$8";"$9";"$7";"$3";"$5";"$6";"$15}' > output.trans`

exit 0

Chris Romano




More information about the wplug mailing list