We help IT Professionals succeed at work.

How to use sed to replace a nonprinting character (ascii 1) in a text file

I am trying to replace a regularly occurring nonprinting character (ascii value 001) in a large text file. I would like to use sed, but I can't find a way to refer to a nonprinting character in the search tag. Can one use nonprinting characters in regular expressions?
Thanks.
nr-26nov07-deflines-RAW-part.txt
Comment
Watch Question

Data Warehouse / Database Architect
SILVER EXPERT
Commented:
Hi migil,

Different versions of sed work differently, so you might have to experiment, but this will work with some seds:

  sed 's/[\x01]//g' old > new

That will delete the 01 characters.  If you want to replace them, just enter the new value between the second and third '/'.


Good Luck,
Kent

Author

Commented:
Thanks Kent,
It was cygwin sed on Win2k.
I suspected something like your suggestion, but could find no documentataion...
Best wishes,
mike

Explore More ContentExplore courses, solutions, and other research materials related to this topic.