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.
(To maintain a SO tradition of proposing multiple answers with different tools for shell scripting questions):
With tr
:
tr -d '\0'
With sed
:
sed 's/\x0/-9/g' filename > newfile
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With