I am trying to parse some logs and there is a strange ^@
symbol in there. I can remove it in vim by cutting that character and paste/searching for it, but how do I remove it in the bash command line automatically.
This doesn't work
sed 's/^@//'
When faced with an unwanted byte in a text file represented by some other stand-in symbol, a tool like hexdump
or od
helps. Try this:
Make a copy of the original file.
Remove everything in the copied file, except a line or two that includes the mystery symbol. Save the file.
To see what the byte really is, do:
hexdump -v -e '/1 "%_ad# "' -e '/1 " _%_u\_\n"' file
From which listing find the hex code for the unwanted byte, (let's say it's 00), and try:
sed 's/\x00//' file
If that works, run the same sed
line on the original file.