Reputation: 2385
I want to remove "^@^@^@^@^@^@^@^@^@" from my textfile. I tried the following, but it did not work:
sed -i 's/\\^@//g' myfile.txt
Upvotes: 0
Views: 96
Reputation: 189926
sed
is not generally robust against null characters. But Perl is, and tr
:
tr -d '\000' <myfile.txt >newfile.txt
Some sed
variants will be able to handle null bytes with the notation which works in Perl:
perl -i -pe 's/\x00//g' myfile.txt
The -i
option says to replace the original file, like some sed
variants also allow you to.
Upvotes: 1
Reputation: 242343
^@
is one of the ways how to display the null byte. sed
(at least the GNU one) represents it as \x00
:
sed 's/\x00//g'
Upvotes: 0