Skip to content
Advertisement

how to remove “^@” from text files in unix?

I am trying to remove “^@” from multiple text files using Unix platform. I have already found this solution, but it does not work for my case. I also used sed -i -e 's/^@//g' testfile.txt and dos2unix testfile.txt. sample data are put here.

Any suggestion would be appreciated.

Advertisement

Answer

The ^@ that you’re seeing isn’t a literal string. It’s an escape code for a NUL (character value 0). If you want to remove them all:

JavaScript

To help diagnose this sort of thing, the od (octal dump) utility is handy. I ran this on the test file you linked, to confirm that they were NULs:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement