Search posts

Linux tr command

tr (stand for translate), is a command that “translate” (transform) one text into anther.
The structure is:tr <textToChange> <newText>
And tr will “translate” (change) textToChange to newText, the rest of the input will just be printed to the screen.

The explain of the example, the tr got to parameters, the first [a-z] and that basically mean any lower case letter, this is what we want to change , the second was [A-Z] and that mean that we want to change it to upper case letter.
Because [A-Z] represent all upper case letters.

We can use -s option to squeeze characters that repeat themselves.
For example to squeeze any repeated spaces into one space.
In the example below we will squeeze all the space in index.html