Convert DATE string to a formatted text

Hi guys, i need your help.

I need to convert a date like this one 20071003071023 , to a formated date
like 20071003 07:10:23 .

Could this be possible ?

Regards,

Osramos

# echo "20071003071023" | awk '{print substr($0,1,8)" "substr($0,9,2)":"substr($0,11,2)":"substr($0,13,2)}'
20071003 07:10:23

echo 20071003071023 | sed 's/\(..\)\(..\)\(..\)$/ \1:\2:\3/'

Hello,

thanks to all who help me, but i make a mystake .

I've got this piece of file

APPLICATION GROUP_NAME MEMNAME ODATE STATUS START_TIME END_TIME

-------------------- -------------------- ------------------------------ ------ ---------------- -------------- --------------

AFT AFTSCMDIVD AFTDIVD1312A 071001 Ended OK 20071002041242 20071002041242

AFT AFTSCMDIVD AFTDIVD0115B 071002 Ended OK 20071003063253 20071003063303

and i want to convert to this :

APPLICATION GROUP_NAME MEMNAME ODATE STATUS START_TIME END_TIME

-------------------- -------------------- ------------------------------ ------ ---------------- -------------- --------------

AFT AFTSCMDIVD AFTDIVD1312A 071001 Ended OK 20071002 04:12:42 20071002 04:12:42

AFT AFTSCMDIVD AFTDIVD0115B 071002 Ended OK 20071003 06:32:53 20071003 06:33:03

like i've told before , all i need is to format the date and time, but i need to have also the file output with all de information.

Is it possible or is more complicated

Have you tried the sed command I provided? It will format the last occurrence, you can easily extent that to cover the date in the second to last field.

Hi, yes i have tried with you sed command like this :

cat report_jobs_CTM.csv | awk '{print $7 $8}' |sed 's/\(..\)\(..\)\(..\)$/ \1:\2:\3/' > new.csv

but the the result was this:

EN D_:TI:ME
-------- --:--:--
2007100204124220071002 04:12:42
2007100204124820071002 04:12:48

Why i am doing wrong ?

awk '{ 
     for(i=7;i<=8;i++) {
       $i=substr($i,1,8)" "substr($i,9,2)":"substr($i,11,2)":"substr($i,13,2)
     }
     {print}
}' "file"