0

I had a "file.txt" with this string and to show the special characters and then replace

my file.txt https://drive.google.com/file/d/1pTh4rxdlmA3Qq0aVwF5jCTK3StqXrQeJ/view?usp=sharing

12,IBA�EZ JUAN,2006,00030,NUEVO

the character � I know is a "Ñ"

I want this

12,IBAÑEZ JUAN,2006,00030,NUEVO

i have tried

tr '\0xd1' 'Ñ' < file.txt  > file_2.txt 

my xxd is

$ hexdump -C file.txt

00000000  31 32 2c 49 42 41 ef bf  bd 45 5a 20 4a 55 41 4e  |12,IBA...EZ JUAN|
00000010  2c 32 30 30 36 2c 30 30  30 33 30 2c 4e 55 45 56  |,2006,00030,NUEV|
00000020  4f 2c 00 2c 20 20 20 20  20 20 20 20 20 20 2c 4e  |O,.,          ,N|
00000030  4f 2c 00 2c 30 30 36 2c  50 2c 37 2e 30 30 30 2c  |O,.,006,P,7.000,|
00000040  2e 30 30 30 2c 31 32 2e  37 34 2c 2e 30 30 30 2c  |.000,12.74,.000,|
00000050  2d 2c 32 30 30 36 2d 30  36 2d 33 30              |-,2006-06-30|
0000005c
Brayan Pastor
  • 874
  • 7
  • 12
  • Could you review this one: https://stackoverflow.com/questions/12649896/why-doesnt-my-terminal-output-unicode-characters-properly – 0xh3xa May 14 '20 at 03:37

1 Answers1

0

Using hexdump, we find that my file is deferring from yours with 3 redundant bytes at the very start.

cat file.txt | hexdump -C

12,IBA�EZ JUAN,2006,00030,NUEVO, ,          ,NO, ,006,P,7.000,.000,12.74,.000,-,2006-06-30

Piping the cat output onto tr command,

cat file.txt | tr -s "�" "Ñ"

$ cat file.txt | hexdump -C
00000000  ef bb bf 31 32 2c 49 42  41 ef bf bd 45 5a 20 4a  |...12,IBA...EZ J|
00000010  55 41 4e 2c 32 30 30 36  2c 30 30 30 33 30 2c 4e  |UAN,2006,00030,N|
00000020  55 45 56 4f 2c 20 2c 20  20 20 20 20 20 20 20 20  |UEVO, ,         |
00000030  20 2c 4e 4f 2c 20 2c 30  30 36 2c 50 2c 37 2e 30  | ,NO, ,006,P,7.0|
00000040  30 30 2c 2e 30 30 30 2c  31 32 2e 37 34 2c 2e 30  |00,.000,12.74,.0|
00000050  30 30 2c 2d 2c 32 30 30  36 2d 30 36 2d 33 30     |00,-,2006-06-30|
0000005f

Again, check for hexdump to check the changes if you want.The original text had 3 unprintable characters which are now replaced by 2 characters: Ñ . Check the screenshot below:

terminal-session

schegu
  • 31
  • 8
  • this is my file.txt https://drive.google.com/file/d/1pTh4rxdlmA3Qq0aVwF5jCTK3StqXrQeJ/view?usp=sharing Sujan Chegu, and i have updated my hexdump – Brayan Pastor May 14 '20 at 05:36
  • @BrayanPastor, I updated the answer, but as I said in the answer, ignore the first three redundant bytes in all the outputs. – schegu May 14 '20 at 07:39