September 10, 2009

awk script for processing comma seperated files

This script remove leading and trailing spaces of each line,
and the field separator is any amount of space, tab mixed with one comma (of course you can also use = or other symbols).

#!/usr/bin/awk -f

BEGIN{
FS=" *, *"
}
{
gsub(/^[ \t]+|[ \t]+$/, "");
printf("|%s|\n",$1);
printf("|%s|\n",$2);
print "===="
}

No comments:

Post a Comment