Operating System - HP-UX
1833106 Members
3129 Online
110051 Solutions
New Discussion

Re: Formating Date in Text file

 
SOLVED
Go to solution
Nabil_2
Advisor

Formating Date in Text file

Hello,
I am working on a project to load a text file in an MYSQL database and looking for some Unix commands that could assist me in changing the Date format in my text file.

Here is how the text file look like:


1 test test1 test2 test3 07-09-2002 test5
1 test test1 test2 test3 07-05-2002 test5
1 test test1 test2 test3 07-03-2002 test5
1 test test1 test2 test3 07-01-2002 test5
1 test test1 test2 test3 07-04-2002 test5


something like that and would like to change the date part to look like this format yyyy-mm-dd


Can any one help me with this ???

Thanks for any help


2 REPLIES 2
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Formating Date in Text file

This is probably most easy to handle in awk.

The attached 2 minute script creates an awk script 'on the fly' and executes it.

Use it like this:
format.sh oldfile > newfile
If it ain't broke, I can fix that.
Nabil_2
Advisor

Re: Formating Date in Text file

WOW, Thank you ... that worked like a charm ..Perfect result ....


Thank you again .. This works for me....