f



unix2dos ( tr '\12' '\15\12' ) doesn't run

Hi,

m3vmsa3.caddebug /tmp > tr  '\12' '\15\12' < foo > foo.tr
m3vmsa3.caddebug /tmp > od -t c foo
0000000    o   n   e  \n   t   w   o  \n   t   h   r   e   e  \n
0000016
m3vmsa3.caddebug /tmp > od -t c foo.tr
0000000    o   n   e  \r   t   w   o  \r   t   h   r   e   e  \r
0000016


Why does tr not add '\12' to foo.tr?

Thanks in advance,
Jose Luis
0
Jose
12/18/2007 12:08:26 PM
comp.unix.shell 15484 articles. 3 followers. Post Follow

1 Replies
701 Views

Similar Articles

[PageSpeed] 12

On Tue, 18 Dec 2007 04:08:26 -0800 (PST), Jose Luis wrote:
>
> Hi,
>
> m3vmsa3.caddebug /tmp > tr  '\12' '\15\12' < foo > foo.tr
> m3vmsa3.caddebug /tmp > od -t c foo
> 0000000    o   n   e  \n   t   w   o  \n   t   h   r   e   e  \n
> 0000016
> m3vmsa3.caddebug /tmp > od -t c foo.tr
> 0000000    o   n   e  \r   t   w   o  \r   t   h   r   e   e  \r
> 0000016
>
>
> Why does tr not add '\12' to foo.tr?
[...]

Because tr is a transliterator. It replaces characters with
other characters not strings with other strings. Use sed
instead:

CR=$(printf '\r')
sed "s/\$/$CR/" < foo > foo.dos

Or u2d or unix2dos or recode...

-- 
Stephane
0
Stephane
12/18/2007 12:13:43 PM
Reply: