First of all, I'm not sure if sed is even the right tool for this job,
but here goes-
I need to send a stream of output from a .net app on a windows box (or
boxen) to a serial port on a Linux machine. Each line has to contain a
preamble which includes unprintable characters. The .net app writes
these in Unicode (e.g. \340 is written as \303\240) which the hardware
device on the serial port can't interpret.
I thought of using a sed script on the Linux box to add the preambles
instead, but I don't know how to get it to echo unprintable characters.
I can get it to add text so long as it's in 7 bits.
The file trace2 contains data in the format "#003 Quantity set to 2".
cat trace2 | sed 's/^#/test#/' gives me the output:
test#003 Quantity set to 2
cat trace2 | sed 's/^#/\027a\340\300\004\340\300\005\340\300\002#/'
027a340300004340300005340300002#003 Quantity set to 2
What I want is the first character to be a ^W ...etc.
I tried dropping the single quotes in case they were forcing sed to
interpret the replacement string literally, but this didn't help.
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!