In Help, Substitute Text ...

i'm writing a script that will extract and substitute a certain part of a data.
i'm having trouble with the substituting part ...

Here's my data looks like:

01/01/08-001-23:46:18-01/01/08-23:50:43
01/01/08-003-23:45:19-01/01/08-23:55:49
01/01/08-005-23:52:18-01/01/08-23:58:52

i want to change the second column i.e. 001,003,005 to:

CODE01 for 001, CODE03 for 003 and CODE05 for 005. so that it will look like this ...

01/01/08-CODE01-23:46:18-01/01/08-23:50:43
01/01/08-CODE03-23:45:19-01/01/08-23:55:49
01/01/08-CODE05-23:52:18-01/01/08-23:58:52

i have separate a file for the list of codes to be substituted. i tried using sed, but can't figure out how.

i'm on: using csh
SunOS 5.8 Generic_108528-22 sun4u sparc SUNW,UltraAX-MP

oh btw, im new here =D

nawk -F- -v OFS=- '$2=sprintf("CODE%02d", $2); print'  myFile.txt

@vgersh99

Thanks ...

just a follow up, i have another database, but with different codes i.e. 001=red,003=blue,005=orange. any suggestion? i tried playing with your code, but no useful results happened.

i'm still newbie in this csh thing ...

How many CODE's you have ..I mean is the number of CODEs finite

finite number of codes

$ cat a.a
01/01/08-001-23:46:18-01/01/08-23:50:43
01/01/08-003-23:45:19-01/01/08-23:55:49
01/01/08-005-23:52:18-01/01/08-23:58:52

$ sed 's/-00\([0-9]\)-/-CODE0\1-/' a.a > b.b

$ cat b.b
01/01/08-CODE01-23:46:18-01/01/08-23:50:43
01/01/08-CODE03-23:45:19-01/01/08-23:55:49
01/01/08-CODE05-23:52:18-01/01/08-23:58:52

what's the format of the 'code' to 'color' mapping? Sample, pls!