I have this file:
$ cat file
1515523  A45678BF141  A11269151
2234545  A45678BE145  A87979746
5432568  A45678B2123  A40629187
7234573  A45678B4154  A98879129
8889568  A45678B5123  A13409137
9234511  A45678B9176  A23589941
3904568  A45678B7123  A52329165
3234555  A45678B1169  A23589497
9643568  A45678B6123  A39969112
1234547  A45678B2132  A40579243
and this script:
cat file | awk '{FS = " "} {print $1" "$3" "$5}'| awk '{
    n = split($3, a, "");
    s = "";
    for (i = 1; i <= n; i += 2) s = s a[i+1] a[i];
    print $1, substr($2, length($2)-3, 4), s
}'| cut -d" " -f3,1  >  output
And when I open the output with vi, I have:
1515523  F141  11621915^M
2234545  E145  78797964^M
5432568  2123  04261978^M
7234573  4154  89781992^M
8889568  5123  31041973^M
9234511  9176  32859914^M
3904568  7123  25231956^M
3234555  1169  32854979^M
9643568  6123  93691921^M
1234547  2132  04752934^M
I don't know why I obtain ^M, because when I intend to run the awk snippet:
cat imei | awk '{FS=" "} {print $2","$1}'
the output is mistaken, i.e., it does not exchange the columns, as it does not print the second column. Any ideas on what may be happening?
 
     
     
     
     
     
    