Need help converting ctlU (^U) to a \12...

I have a file that ends with a ctlU:

> cat -v test.file 
blah,blah,blah,GEAEA*1*xx0000111xxx^UIEA*xxx0^U

would like to replace the ctlU (^U) with a "\12"...due to printers or something.

I believe I might be able to utilize the tr command, if I could only identify the correct representation for ctlU (^U)?

tr '\^U' '\12' < test.file > new.file

any assistance would be appreciated...
manny

To get octal value of that character, use:

od -c test.file

The tr needs a different notation than ^X? Try \octal, \25 in this case.

> cat test.file | od -c | tail -2
0006600   7   9   0 025  \n
0006605
> cat test.file | od -b | tail -2
0006600 067 071 060 025 012
0006605

looks like the following did the trick...thanks :slight_smile:

> tr '\025' '\12' < test.file > new.file

It works for me using keyboart cntl-u in single quotes:

$ all256|cat -vt
^@^A^B^C^D^E^F^G^H^I
^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~^?M-^@M-^AM-^BM-^CM-^DM-^EM-^FM-^GM-^HM-^IM-
M-^KM-^LM-^MM-^NM-^OM-^PM-^QM-^RM-^SM-^TM-^UM-^VM-^WM-^XM-^YM-^ZM-^[M-^\M-^]M-^^M-^_M- M-!M-"M-#M-$M-%M-&M-'M-(M-)M-*M-+M-,M--M-.M-/M-0M-1M-2M-3M-4M-5M-6M-7M-8M-9M-:M-;M-<M-=M->M-?M-@M-AM-BM-CM-DM-EM-FM-GM-HM-IM-JM-KM-LM-MM-NM-OM-PM-QM-RM-SM-TM-UM-VM-WM-XM-YM-ZM-[M-\M-]M-^M-_M-`M-aM-bM-cM-dM-eM-fM-gM-hM-iM-jM-kM-lM-mM-nM-oM-pM-qM-rM-sM-tM-uM-vM-wM-xM-yM-zM-{M-|M-}M-~M-^?$ 
$ all256|tr '^U' ' '|cat -vt
^@^A^B^C^D^E^F^G^H^I
^K^L^M^N^O^P^Q^R^S^T ^V^W^X^Y^Z^[^\^]^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