[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: fixing .txt files sent from a MS$ user

Douglas A. Tutty wrote:

> Hello all,
> My niece sends some of her schoolwork to my wife (e.g. essays) for her
> to read.  First she sent .doc files which I can't access properly (no, I
> do no run OO) although I could get the jist.  I then suggested that she
> send plain text.
> I don't run any locales but have LANG=C.
> Her plain-text files are fine, except that apostrophies (singel-quote)
> (') are replaced with "\222", opening quotes (") with "\223", and
> closing quotes (") with "\224".
> Other than writing a python script, can someone give me a simple command
> to fix this so that it is not so distracting?  Ideally, I'd put it into
> an executable file and pipe the file through it on it's way to lpr.
> e.g. 
> $ cool-writing.txt | antiAJ | lpr -Pepson

Use tr?  It's a very simple program meant for exactly this kind of task.
The first argument is the list of characters to replace, and the second
is the list of characters (in order) to replace them with.

tr "\222\223\224" \'\"\" < cool-writing.txt | lpr -Pepson

N.B. the ' and " characters need to be escaped from the shell in the
second argument on the command line above.

tr is even in "coreutils" so you don't have to install anything extra.

best regards,

Kevin B. McCarty <kmccarty@gmail.com>
WWW: http://www.starplot.org/
WWW: http://people.debian.org/~kmccarty/
GPG: public key ID 4F83C751

Attachment: signature.asc
Description: OpenPGP digital signature

Reply to: