transposing data {awk?}

David C Lawrence tale at pawl.rpi.edu
Fri Nov 24 08:39:04 AEST 1989


In <4473 at netcom.UUCP> beaulieu at netcom.UUCP (Bob Beaulieu) writes:
Bob> Is it possible to use awk to change the 7th field of "YYMMDD" to
Bob> show "MM/DD/YY" by using the awk command?

Sure; in fact, it's trivial.  Please try and get a hold of any basic
AWK reference manual; even the crummy SunOS manual page for awk makes
mention of the features you need.

You'll probably end up with something like this:

awk '{ $7 = sprintf("%s/%s/%s",substr($7,2,2),substr($7,4,2),substr($7,0,2));\
       print; }'

Dave
-- 
 (setq mail '("tale at pawl.rpi.edu" "tale at ai.mit.edu" "tale at rpitsmts.bitnet"))



More information about the Comp.unix.questions mailing list