29

I have a huge text file containing this string/character <200b> that I want to delete. I tried with sed but it didn't work.

sed 's/<200b>//g' file

The character never shows when I open the file with a graphic text editor like gedit, I see it with vim.

Jason Aller
  • 2,360

6 Answers6

38

You can also get rid of this in VIM.

%s/\%u200b// - entire file
%s/\%u200b//g - entire file, more than one occurrence on a line
mmrtnt
  • 481
35

<200b> is a Unicode for "Zero Width Space". You won't find it as a string. You can pipe the character into sed like this for removal:

sed -i "s/$(echo -ne '\u200b')//g" file
Pablo A
  • 1,733
1

For anyone using vim and want to remove whole lines with this character, you can use the ex command g

:g/\%u200b/d
ybl
  • 111
1

I would recommend open this file in any Text editor and do a Find and Replace.

Find: Hold Alt and press 0 1 2 9 (this will input a zero-width character).

Replace: Leave empty.

Choose "Replace all".

Mike
  • 575
0

Using vi, for all lines (1,$) substitute (s) all zero-width-space instances per line by nothing (//g):

:1,$s/\%u200b//g
0

A shorter version of the same suggestion:

:%s/\%u200b//g