next up previous contents
Next: Comparing sorted file with Up: Filters: cool objects Previous: Filters: cool objects   Contents

Character transliteration with tr

The tr command transliterates the characters in its input. A common use is for case conversion. For example:

cat doc1.txt | tr a-z A-Z

converts lower case to upper case, and the following does the reverse:

cat doc2.txt | tr A-Z a-z

The following example prints one word per line from a normal English text file, where word is any sequence of upper/lower case letters and the apostrophe.

tr -cs "A-Za-z'" "[\012*]"



Amit Jain 2013-04-22