usage of tr

Robert kerplop at sbcglobal.net
Tue Apr 8 16:39:29 UTC 2008


Aaron Bliss wrote:
> Hi everyone,
> I'm trying to figured out how to remove and instance of ^ followed by 
> and upper case H from a file.When I use tr -d [^H] tr is removing the 
> sequences with ^ characters as well as any upper case H's found in the 
> file.   Any ideas?  thanks.
> 
> Aaron
> 

I assume the objective is removal of "^H" sequences (eg ASCII 
representation of the BS char) from a string, not necessarily 
exploration of the uses of the tr command. If so, try:
[rj at mavis ~]$ sed -e s/"\^H"/""/g
...which is expecting standard input to supply the string. Then, type 
(without the quotes) "HHH^H^H^HhhhHHHABCDEFG...", press <enter> and read 
the stripped string. Like this:
[rj at mavis ~]$ sed -e s/"\^H"/""/g
HHH^H^H^HhhhHHHABCDEFG...
HHHhhhHHHABCDEFG...

All that remains is to cause sed to operate on a file rather than 
standard input.
(Yeah, I know about driving tacks with a sledgehammer but that works a 
lot better than driving railroad spikes with a tackhammer.)




More information about the redhat-list mailing list