问题
I have a flat file generated from someone else's software. They insert the null character ^@ in certain positions of the file. I wish to replace them with something else like -9. How do I search and replace this character efficiently in terminal on Mac OS X?
Thanks.
There is another post addressing this question in linux.
回答1:
(To maintain a SO tradition of proposing multiple answers with different tools for shell scripting questions):
With tr:
tr -d '\0'
回答2:
With sed:
sed 's/\x0/-9/g' filename > newfile
来源:https://stackoverflow.com/questions/14881821/replacing-the-null-character-in-a-flat-file