[comp.unix.questions] It seems I cannot do this with tr

phil@ux1.cso.uiuc.edu (Phil Howard KA9WGN) (06/01/91)

What I want to do is to translate ALL characters EXCEPT the ones I can
provide a list of, to some other character (all will be to the same one).
For instance if my character list has '[A-Z]' and the other character
is '.', then my output would have only A-Z and (probably) lots of dots.
I could use "tr" if it was practical to generate the list of ASCII
characters NOT in the list I have, but I am just wondering if a simpler
solution exists.  If not, I'll write a C program.
-- 
 /***************************************************************************\
/ Phil Howard -- KA9WGN -- phil@ux1.cso.uiuc.edu   |  Guns don't aim guns at  \
\ Lietuva laisva -- Brivu Latviju -- Eesti vabaks  |  people; CRIMINALS do!!  /
 \***************************************************************************/

rouben@math16.math.umbc.edu (Rouben Rostamian) (06/01/91)

In article <1991May31.222945.18640@ux1.cso.uiuc.edu> phil@ux1.cso.uiuc.edu (Phil Howard KA9WGN) writes:
>What I want to do is to translate ALL characters EXCEPT the ones I can
>provide a list of, to some other character (all will be to the same one).
>For instance if my character list has '[A-Z]' and the other character
>is '.', then my output would have only A-Z and (probably) lots of dots.

Use the flag -c ("c" for complement) with tr:

tr -c A-Z . <infile >outfile

--
Rouben Rostamian                          Telephone: (301) 455-2458
Department of Mathematics and Statistics  e-mail:
University of Maryland Baltimore County   bitnet: rostamian@umbc.bitnet
Baltimore, MD 21228,  U.S.A.              internet: rouben@math9.math.umbc.edu