remove <200b> character from text file

12

2

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.

user2598997

Posted 2015-03-08T23:33:20.037

Reputation: 121

Please see this link, it helped me find <200b> in my text file: https://unix.stackexchange.com/questions/59447/replace-unicode-chars-in-vim

– Nanda – 2017-08-25T00:08:54.617

Answers

14

<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

sirEgghead

Posted 2015-03-08T23:33:20.037

Reputation: 141

1Welcome to superuser: The answer maybe correct but would be better if it was surrounded with some detail on what you have done, how to use, etc. for people that may not understand and search answers in days or years to come. – mic84 – 2018-05-10T04:52:57.097

there was no down vote from me – mic84 – 2018-05-10T05:06:11.213

Combining sed and echo -ne is even more elegant than all this answers

– Pablo A – 2019-07-18T22:55:07.637

6

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

Posted 2015-03-08T23:33:20.037

Reputation: 61

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

Posted 2015-03-08T23:33:20.037

Reputation: 517

Depending on how "huge" the text file is, some text editors won't work on it. – mpez0 – 2015-03-08T23:56:58.030

Hi. I already tried this but it tells me that the string is not found. The file has 5 million lines. – user2598997 – 2015-03-09T00:01:39.550

You have to detect how to input the same symbol as used in this file. And then use FART or Ser tool (as your file is really huge) to find and replace. I see no other option, but it doesn't mean it's not exist. Let's see if someone will post anything more effective. – Mike – 2015-03-09T00:06:01.250

I need to add an info. the character never shows when i open the file with a graphic text editor, i see it with vim. – user2598997 – 2015-03-09T00:13:14.113