![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community. |
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Compare date from db2 table to yesterday's Unix system date | sasaliasim | Shell Programming and Scripting | 9 | 12-01-2008 11:37 PM |
| Perl: Extracting date from file name and comparing with current date | MKNENI | Shell Programming and Scripting | 4 | 03-26-2008 04:01 PM |
| date issue-find prevoius date in a patricular format | bsandeep_80 | UNIX for Advanced & Expert Users | 3 | 11-15-2007 08:42 PM |
| Changing Creation Date to a Prespecified Date of a File In Unix | monkfan | UNIX for Dummies Questions & Answers | 4 | 11-28-2006 07:15 AM |
| a simple way of converting a date in seconds to normal date | travian | HP-UX | 2 | 11-23-2006 12:25 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
date
Input file:
Code:
E102,0,21/22/1995,0,2/2/1996,E003,A,125400,10450,60.2884620 E102,0,11-23-1994,0,2/25/1994,E003,A,125400,10450,60.2884620 E103,0,1/23/1994,0,12-27-1995,E003,A,125400,10450,60.288462 E104,0,9/25/1994,0,8-10-1995,E003,A,125400,10450,60.288462 E104,0,10-APR-1994,0,8-OCT-1995,E003,A,125400,10450,60.288462 Code:
BEGIN {
FS=OFS=","
}
{
split($3, a, "/")
if (a[1]<10) a[1]=0a[1]
if (a[2]<10) a[2]=0a[2]
$3=a[3] a[1] a[2]
split($3, a, "-")
if (a[1]<10) a[1]=0a[1]
if (a[2]<10) a[2]=0a[2]
$3=a[3] a[1] a[2]
split($5, a, "/")
if (a[1]<10) a[1]=0a[1]
if (a[2]<10) a[2]=0a[2]
$5=a[3] a[1] a[2]
split($5, a, "-")
if (a[1]<10) a[1]=0a[1]
if (a[2]<10) a[2]=0a[2]
$5=a[3] a[1] a[2]
split($NF, a, "/")
if (a[1]<10) a[1]=0a[1]
if (a[2]<10) a[2]=0a[2]
$NF=a[3] a[1] a[2]
split($NF, a, "-")
if (a[1]<10) a[1]=0a[1]
if (a[2]<10) a[2]=0a[2]
$NF=a[3] a[1] a[2]
print
}
Code:
E102,0,199521220,0,199602020,E003,A,125400,10450,60.288462000 E102,0,199401123,0,199402250,E003,A,125400,10450,60.288462000 E103,0,199401230,0,199501227,E003,A,125400,10450,60.28846200 E104,0,199409250,0,199500810,E003,A,125400,10450,60.28846200 E104,0,10-APR-1994,0,8-OCT-1995,E003,A,125400,10450,60.288462 the output should be E104,0,19940410,0,19951008,E003,A,125400,10450,60.288462 Pls help me on this ASAP. Thanks, Charan Last edited by Yogesh Sawant; 04-07-2008 at 03:42 AM.. Reason: added code tags |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|