Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 24 Nov 2001 00:31:22 -0600
From:      Glenn Johnson <glennpj@charter.net>
To:        questions@freebsd.org
Subject:   date conversion in awk
Message-ID:  <20011124063122.GA2811@gforce.johnson.home>

next in thread | raw e-mail | index | archive | help
I have a set of files that have, as part of their content, dates in the
following format:

23-Nov-01

I need to convert the format to:

11/23/2001

I know how to do the conversion with the date command for a single value
but I can not quite figure out how to parse through the file with awk to
change the format.

What I have come up with so far is to extract the date field from the
file and save those values in a variable.  I then loop over the contents
of the variable, do the conversion, and write them out to a file.  I
then run awk on the original file to get whatever else I need and then
paste the results of this and the dates file into another file using the
paste command.

This works but it seems that I should be able to do the date conversion
while in awk without having to write the converted dates out to an
intermediate file.

Any help appreciated.  Thanks.

-- 
Glenn Johnson
glennpj@charter.net

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011124063122.GA2811>