tr problem

Mikkel L. Ellertson mikkel at infinity-ltd.com
Thu Jun 12 21:53:57 UTC 2008


Gene Heskett wrote:
> Hi folks;
> 
> I'm trying to convert a test file, src code for a legacy computer, whose eol is 
> a single cr into one with a newline subbed for each cr, and tr is being a pita, 
> it broken, or there is PEBKAC.
> 
> If I use this syntax:
> 
> tr -c \r \n <filename  >filename2
> 
> Then the whole file is converted to nnnnnnnnnn's, every byte.
> 
> The manpage (and pinfo tr too) is, shall we say, completely lacking in how to 
> handle the file I/O.
> 
> So how do you use tr?"
> 
> Or is there a better tool for this than tr?
> 
> Thanks.
> 
When the man page says that the -c option causes tr to first 
complement SET1, another way to say it is that using -c will cause a 
matche to everything but SET1.

The reason file I/O in not covered is that tr is normally a filter, 
so you would use in a pipe between two other programs. It takes what 
comes in from stdin, does its thing, and sends it to stdout. This is 
common among filter programs. Another thing common among filter 
programs is that they will not have any opening message, and will 
send errors to stderr.

Mikkel
-- 

   Do not meddle in the affairs of dragons,
for thou art crunchy and taste good with Ketchup!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/fedora-list/attachments/20080612/b81e57e3/attachment-0001.sig>


More information about the fedora-list mailing list