Merge two input files and concatenate the rest

Hi Guys,

I need a help to creating a bash script to merging two files that containing not in order pattern into single file also within that single file I need to concatenate and manipulate the string from two files. Appreciate for any kind help given.

Thanks.

Here are the input files:
File1

A00018-04,1M,2014-09-15T10:12:36.762Z 
A00025-08,2M,2014-09-19T09:41:48.610Z 
A00025-10,3M,2014-09-15T10:12:36.988Z 
A00033-03,1M,2014-09-15T10:12:36.762Z 
A00037-01,5M,2014-09-11T04:10:47.840Z 
A00040-03,BYPASS,2014-09-02T04:10:11.710Z 
A00054-01,5M,2014-09-15T10:12:36.762Z 
A00055-01,15M,2014-09-15T10:12:36.988Z
A00055-03,15M,2014-10-28T10:32:50.897Z
A00058-01,2M,2014-09-15T04:32:53.020Z

File2

A00018-04,ABC111,2014-10-29T07:29:56.347Z
A00037-01,ABC555,2014-10-29T07:33:29.287Z
A00025-08,ABC222,2014-10-29T07:30:35.426Z
A00040-03,ABC666,2014-09-02T05:16:50.492Z
A00025-10,ABC333,2014-10-29T07:31:45.609Z
A00033-03,ABC444,2014-10-29T07:33:00.567Z
A00054-01,ABC777,2014-10-29T07:34:05.975Z

Desire output:

A00018-04_ABC111(1M)
A00025-08_ABC222(2M)
A00025-10_ABC333(3M)
A00033-03_ABC444(1M)
A00037-01_ABC555(5M)
A00040-03_ABC666(BYPASS)
A00054-01_ABC777(5M)
A00055-01_NO-DESCRIPTION(15M)
A00055-03_NO-DESCRIPTION(15M)
A00058-01_NO-DESCRIPTION(2M)

You could try something like:

awk -F ',' '
FNR == NR { a[$1] = $2; next }
{ printf("%s_%s(%s)\n", $1, ($1 in a) ? a[$1] : "NO-DESCRIPTION", $2) }' File2 File1

If you want to try this on a Solaris/SunOS System, change awk to /usr/xpg4/bin/awk , /usr/xpg6/bin/awk or nawk .

With join and sed

Both File1 and File2 have to be sorted.

join -t',' -1 1 -2 1 -a 1 -e 'NO-DESCRIPTION' -o '1.1,2.2,1.2' File1 File2 | sed -e 's/,/_/' -e 's/,/(/' -e 's/$/)/'

My versions of join and sed are as below
join (GNU coreutils) 8.23
sed (GNU sed) 4.2.2

Hi Don and ni2, thank you so much for your feedback and help. It is seem Don's method is suitable for my case.

Thanks again guys.