Remove the \r \n from the variable

I a have a delimited file that has a 2 column which I need to read and pull out both columns from the file.Now the while pulling out the second column and storing in a variable I get a \r\n charachter embedded in the output when an od -c is run.How can I remove the \r\n columns from the file.

example : File name : XYZ.DAT

Column 1!$#$!Column 2
ABC!$#$!123
DEF!$#$!456

This is the command I run :

SN_PRD_FILE_CNT=`cat XYZ.DAT | head -2|tail -1 | awk -F '[!][$][#][$][!]' '{print $2}' |od -c

When storing in a variable and redirecting the same to an output file I get the enter (\r\n) included.need to attain only 123

It's a bit unclear. You mean both columns from all rows, or both second columns, from the file?

Show what output you expect.

$ SN_PRD_FILE_CNT=$($ awk -F '[$#!]' 'NR==2{print $1,$NF}' ORS=" " XYZ.DAT)
$ echo $SN_PRD_FILE_CNT                                                                              
ABC 123 DEF 456

Another awk approach:

awk '{gsub(/.*!|\r/,X);print}' ORS= XYZ.DAT | od -c 

To store it in variable:

SN_PRD_FILE_CNT=$( awk '{gsub(/.*!|\r/,X);print}' ORS= XYZ.DAT )
SN_PRD_FILE_CNT=`cat XYZ.DAT | head -2|tail -1 | perl -pne 'chomp' - |awk -F '[!][$][#][$][!]' '{print $2}' |od -c