Source file is having a special character in starting of each row. File is double space delimited.
Sample data file:
âNAME ABC
âAGE 21
âADDRESS XYZ street ABC city
âCONTACT 13244235
âDOJ 20181212
I want to remove â
as its first and special character in each line and convert file to ;
(semicolon) delimited file.
Below code I have written which is working fine in UAT but its not working correctly in PROD:
awk '{ print substr($0,1) }' FILE1.txt | sed 's/ /;/' > FILE2.txt
UAT output (desirable output which is expected):
NAME;ABC
AGE;21
ADDRESS;XYZ street ABC city
CONTACT;13244235
DOJ;20181212
PROD output:
âNAME;ABC
âAGE;21
âADDRESS;XYZ street ABC city
âCONTACT;13244235
âDOJ;20181212
Same code is working fine in UAT i.e removing first character and converting file to ;
semicolon delimited, But in PROD its not removing 1st special character but converting file to semicolon delimited.
Output of locale
:
locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
Can anyone help me out on this ..?
sed 's/^â//' 's/ /;/' FILE1.txt > FILE2.txt
which might fix the problem with theâ
(probably not though since I suspect that's an encoding issue and not an actualâ
), but would only change the first space on each line to a;
. But that's precisely why you shouldn't post things like that as comments. It was a "wrong" solution since it wouldn't actually work as intended, but nobody could downvote it.sed -n '/^â/p' FILE1.txt
has output on your PROD machine? Also, what is "UAT" and "PROD"? What are the differences between them? Whatlocale
settings do the two machines have?