remove characters that are different from ABCD in a file

P

papori

Guest
Hi guys!
I have a text file, and I want to delete all the characters that are not A,B,C and D.
For example if my file contain this 2 lines:
ABCDEFGHIJ
GHKLABC

the new file will look like:
ABCD
ABC

I am looking for an easy way.. ideas?

Thanks,
Pap
 



If you remove all characters other than A, B, C, and D, that will not
be the result; it will also remove the newline:
Code:
tr -dc 'ABCD' < "$file"
The result will be:
ABCDABC

What you want is:

Code:
tr -dc 'ABCD\n' < "$file"
 

Members online


Top