date field manipulation

I have a data file. Seperated by "|". The 19 th filed is a date field that occurs like this

11/02/2001

i need to convert into the below format

2001-11-02

for e.g..

i/p

o/p should be

can somebody throw some light

I need to do this for all records in the file

First off, your date field is not 19, but rather 18 (based on your sample).

 nawk -F'|' '{split($18,a,"/");$18=a[3]"-"a[1]"-"a[2]}1' OFS="|" myFile

Thanks Vgresh. Is there a way we can do it in sed. I am using couple of other sed commands on the file. Hence would like to see if we can do it in sed.

Probably, but why bother - use the tool better suited for the task.
Most likely your other sed 'commands' might be migrated to awk.

If you are sure there is only one date field per line in field 18 that needs to be changed, or any other field that contains a date, needs to be changed as well, you can could use this:

sed 's|\(..\)/\(..\)/\(....\)|\3-\1-\2|g' infile

But like vgersh99 says, awk is more suited for the task. It is more accurate since it will only modify field 18.

# cat datet
1|147431|3284924|Superliner|1652382|765x125||Delta flight|1 x 1 Default Ad, 34|Superliner 765x125|ion|rt|rt|332|0|0.0|Clicks|05/07/2010|0|332|0|0|Y
# sed 's@|\([0-9][0-9]\)/\([0-9][0-9]\)/\([0-9][0-9]*\)@|\3-\1-\2@g' datet
1|147431|3284924|Superliner|1652382|765x125||Delta flight|1 x 1 Default Ad, 34|Superliner 765x125|ion|rt|rt|332|0|0.0|Clicks|2010-05-07|0|332|0|0|Y