Re: usage of tr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@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@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.)

--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux