I have many data files needing to be parsed and reformatted. The parsing
is easy using the print statement, but I'm struggling to find an awk string
manipulation function that reformats each field. Reading "Effective awk
Programming, 4th Ed." leaves me uncertain whether to use sub(), gsub(),
gensub() or something else.

  A trio of parsed lines look like this:

19881001 003000 0.75
19881001 010000 0.75
19881001 013000 0.75

  What I want for output is this:

1988-10-01 00:30 0.75
1988-10-01 01:00 0.75
1988-10-01 01:30 0.75

  The first field is a date, the second a time in hours and minutes (seconds
are always zero), the third is the value associated with that date and time.

  The split() function, as I understand it, will split the line and assign
each field to an array. That's not what I want. The sub() family will
substitute characters based on regex and string position; I don't want this
either.

  I think that what I need is grouping each field by the number of digits,
then back referencing each group and separating with the appropriate
character (- or :) and my attempts to do this have failed.

  Pointers to resources that will teach me what I need to learn are needed.

TIA,

Rich

_______________________________________________
PLUG mailing list
PLUG@pdxlinux.org
http://lists.pdxlinux.org/mailman/listinfo/plug

Reply via email to