[lug] awk question
Harris, James
James_Harris at maxtor.com
Tue Jan 28 13:35:59 MST 2003
> BEGIN { FS = ","
> myfs = "|"
> }
> { print "On input " NF " fields: " $0 }
>
> { j = 1
> f[j] = $1
> for (i = 2; i <= NF; i++) {
> if (f[j] ~ /^".*[^"]$/) {
> f[j] = f[j] FS $i
> } else {
> j++
> f[j] = $i
> }
> # print "j = " j " i = " i " f[j] = " f[j]
> }
> }
> { record = f[1]
> for (i = 2; i <= j; i++) {
> record = record myfs f[i]
> }
> }
> { print "On output " j " fields: " record }
>
Yah know, I'd like to think that I would have come up with that, but I'm not
entirely sure that's on par with reality. :)
Well that's pretty stinking cool, thanks a bunch. I'll stick it in with the
rest of what I'm doing and see if it cranks out the good juice.
Thanks a lot to everyone for the input and education! Hopefully what I'm
doing will render some good information. (Trying to do some really detailed
analysis on spam in the corporate environment. I've already had some
surprises, so it's going to be really interesting to see how some of the
rest of what I'm doing pans out. Hopefully we'll learn something valuable
from this.)
Jim
More information about the LUG
mailing list