Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Jan 2007 05:41:48 +0200
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        Gary Kline <kline@tao.thought.org>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: perl substitution question
Message-ID:  <20070114034148.GC2734@kobe.laptop>
In-Reply-To: <20070114024551.GA21847@thought.org>
References:  <20070114024551.GA21847@thought.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2007-01-13 18:45, Gary Kline <kline@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@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@kobe:/home/keramida$ perl -pe 's/\x80/"/; s/\x9d/"/;' < binary.dat 
| "hello world"
| keramida@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.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070114034148.GC2734>