I am using the following command to replace the non-ASCII characters, single quotes and non printable characters:
sed -i -e "s/'//g" -e's/'//g' -e's/[\d128-\d255]//g' -e's/\x0//g' filename
However, I am getting an error:
sed: -e expression #3, char 18: Invalid collation character
How can I replace these characters?
'
are all ASCII. Why would you want to replace those? Please [edit] your question to explain. – Chris Davies Jan 21 '16 at 15:37'
has no special meaning. – Chris Davies Jan 21 '16 at 16:59tr -cd '[[:print:]]'
instead ofsed
might be worth a look (-d
: delete,-c
the complement of). – Ulrich Schwarz Jan 21 '16 at 17:05LC_COLLATE=C
for the command. And I second Ulrich's recommendation to delete the non-printing characters usingtr
. – Toby Speight Oct 20 '21 at 07:57