The following worked:
tr -cd '\11\12\15\40-\176' < file-with-binary-chars > clean-file
referred from here:
Domanda
I have a file myFile.xml
which
I want to run the xmllint
command on for proper formatting.
It contains the ASCII character 26 (substitute char) because of which xmllint
command is failing with parser error.
How can I replace all occurrences of this character with blank in this file?
Soluzione
The following worked:
tr -cd '\11\12\15\40-\176' < file-with-binary-chars > clean-file
referred from here:
Altri suggerimenti
If you are using bash
, how about this:
sed $'s/\x1a//g' < FILENAME | xmllint
This uses the special bash
notation $'...'
which tells the bash
to evaluate backslash sequences like the \x1a
properly.