tr
Last modified: January 18, 2007
This page refers to the tr command, an translate command used to translate strings or patterns from one set of characters to another.
Translate does not take a filename as an argument, it only acts on a stream of characters.
Example:
Hamish 35
We now want to translate that to:
HAMISH 35
without editing the file. Cat-ting our file (columns.txt) and then piping the output of the cat command to the input of the translate command causing all lowercase names to be translated to uppercase names.
cat columns.txt | tr '[a-z]' '[A-Z]'
Remember we have not modified the file columns.txt so how do we save the output? Simple, by redirecting the output of the translate command with ‘>’ to a file called UpCaseColumns.txt with:
cat columns.txt | tr '[a-z]' '[A-Z]' > UpCaseColumns.txt
References:


Recent Comments