Sed - remove special characters

Hi,

I have a file with this line, it's always in the first line:

I want to remove these special characters: �

file1

�\\bar\c$\test2\;3.348.118 Bytes;160 ;3
\\bar\c$\test\;35 Bytes;2 ;1

I want the same file to be only

\\bar\c$\test2\;3.348.118 Bytes;160 ;3
\\bar\c$\test\;35 Bytes;2 ;1

I am not able to remove those chars,

In principle not too difficult:

$ sed 's/^�//' file1

, but you should be aware that these character graphics chars usually belong to a multibyte character set like utf-8 or so which may impose restrictions.

1 Like

Can you paste the output of head -1 file1 | od -c for us so we can see the exact byte codes you have in this file.

1 Like

Or to remove multibyte characters, you could try:

LANG=C tr -d '[\200-\377]' < infile
1 Like
 
 
This is what I got 

$ head -1 lista1.csv | od -c
0000000 357 273 277 \ \ n a k a m a \ c o m p
0000020 a r t \ ; 9 4 . 2 6 0 . 9 7 4
0000040 B y t e s ; 7 ; 1 \r \n
0000055
 

---------- Post updated at 11:16 AM ---------- Previous update was at 11:16 AM ----------

Thanks, but I'm afraid this didn't work

---------- Post updated at 11:18 AM ---------- Previous update was at 11:16 AM ----------

That has worked perfectly,

Thank you very much.