> BEGIN {
> space = "[ \t]";
> blanks = space "*";
> blankline = "^" blanks "$";
> comment = "^" blanks "#";
> }
>
> $0 ~ comment {
> print;
> next;
> }
>
> $0 ~ blankline {
> print;
> next;
> }
>
> {
> numlinks = split($4, links, ",");
> newlinks = links[1] "/0";
> for (i = 2; i <= numlinks; i++) {
> newlinks = newlinks "," links[i] "/0";
> }
> print $1 "\t" $2 "\t" $3 "\t" newlinks "\t" $5 "\t" $6 "\t" $7
> }
>
> Since I'm no awk/nawk expert, I'm sure the above script could be made
> more compact or cleaner. So, awk experts, what say you?
>
I think you can shorten it to:
#!/usr/bin/nawk -f
/^[ \t]*#/ || /^[ \t]*$/ {
print;
next;
}
{
numlinks = split($4, links, ",");
newlinks = links[1] "/0";
for (i = 2; i <= numlinks; i++) {
newlinks = newlinks "," links[i] "/0";
}
print $1 "\t" $2 "\t" $3 "\t" newlinks "\t" $5 "\t" $6 "\t" $7
}
--
meem
_______________________________________________
networking-discuss mailing list
[email protected]