perl substitution question

Giorgos Keramidas keramida at ceid.upatras.gr
Sun Jan 14 03:42:31 UTC 2007


On 2007-01-13 18:45, Gary Kline <kline at tao.thought.org> wrote:
> Anybody know if I can do a perl substitution of the scads of
> \x80\x9D to simple double-quotes (") from the command line?

You already have part of the syntax right:

,----------------------------------------------------------------
| keramida at kobe:/home/keramida$ hd binary.dat 
| 00000000  80 68 65 6c 6c 6f 20 77  6f 72 6c 64 9d 0a        |.hello world..|
| 0000000e
| keramida at kobe:/home/keramida$ perl -pe 's/\x80/"/; s/\x9d/"/;' < binary.dat 
| "hello world"
| keramida at kobe:/home/keramida$ 
`----------------------------------------------------------------

Note how the file `binary.dat', which I edited with hexl-mode in Emacs,
to insert the 0x80 and 0x9D hex values, gets converted to "hello world"
on output.



More information about the freebsd-questions mailing list