Replace pattern from nth field from a file

I have posted this again as old post is closed and I am not able to reopen. so please consider this new post

Input File :

1,A,Completed,06.02_19.36,Jun 30 20:00
2,BBB,Failed,07.04_05.12,Jul 21 19:06
3,CCCCC,New,07.21_03.03,Jul 26 12:57 
4,DDDDD,Pending,,

I wast output file as:

1,A,Completed,Jun 02 19:36,Jun 30 20:00
2,BBB,Failed,Jul 04 05:12,Jul 21 19:06
3,CCCCC,New,Jul 21 03:03,Jul 26 12:57 
4,DDDDD,Pending,,
07.21_03.03 is in format of MM.DD_HH.mm

In the above file 4th field is date which is in MM.DD_HH.mm format and I need to convert it to as it to into MON DD HH:mm . Note It can have blank value or space as well.
MM means Month like for 07 means July
DD means day like 21 means 21th day of that month
HH means hour
MIN means minute
MON means Month in 3 letter like for July it should be Jul

Any idea how I can do that in unix shell script with sed or awk or any other command ?

What code have you tried?

I have tried below command but it is replacing complete string not specified pattern.
I am not sure how to check for sub string here so please help.

awk -F, '{ OFS="," ; if ($4 ~ /07/) {$4="\"Jul\""}; if ($4 ~ /06/) {$5="\"Jun\""}; }1' File_Name

awk -f amit.awk myFileGoesHere where amit.awk is:

BEGIN {
  FS=OFS=","
  split("Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec", mon, FS)
}
$4 {
    split($4, a, "[._]")
    $4 = sprintf("%s %02d %02d:%02d", mon[a[1]+0], a[2], a[3], a[4])
}
1

Thanks vgersh99

It worked fine.

It would be very helpful if you can please explain what [._.] is doing and how it split 4th column into array and value assign to each array ?

man awk yields:

       split(s, a [, r [, seps] ])
                               Split the string s into the  array  a  and  the
                               separators array seps on the regular expression
                               r, and return the number of fields.   If  r  is
                               omitted,  FS is used instead.  The arrays a and
                               seps are cleared first.  seps is  the  field
                               separator matched by r between a and a[i+1].
                               If r is a single space, then leading whitespace
                               in  s goes into the extra array element seps[0]
                               and trailing whitespace  goes  into  the  extra
                               array  element  seps[n],  where n is the return
                               value  of  split(s,  a,  r,  seps).   Splitting
                               behaves   identically   to   field   splitting,
                               described above.

In reference to "what [._.] is doing" which vgersh99 didn't fully explain...

Note that the extended regular expression vgersh99 used was [._] (not [._.] , although in this specific case it would do the same thing but take slightly longer to do it). That expression used as the third parameter to split() says that each occurrence of the <period> and <underscore> characters is to be used as a field separator when scanning the string found in the 4th field on that input line to split out substrings into elements in the array named a[] .

For this particular case, this might work as well.

perl -pe '
    BEGIN{ %m = map{++$i => $_} qw(Jan Feb Mar Apr May Jun Jul Aug Sept Oct Nov Dec)};
    s/(\d+).(\d+)_(\d+).(\d+)/$m{int($1)} $2 $3:$4/;
' File_Name

If other fields could contain date material that might interfere, then:

perl -plaF, -e '
	BEGIN{ %m = map{++$i => $_} qw(Jan Feb Mar Apr May Jun Jul Aug Sept Oct Nov Dec)};
	$orig = $F[3];
	$F[3] =~ s/(\d+).(\d+)_(\d+).(\d+)/$m{int($1)} $2 $3:$4/;
	s/$orig/$F[3]/;
' File_Name