tr

translate or delete characters

copy
162
36
tr '[:lower:]' '[:upper:]'Convert lowercase to uppercase

details |

copy
116
40
tr -s '\n'Convert each sequence of repeated newlines to a single newline

details |

copy
33
6
tr -d '[=-=]axM'character class notation `[=c=]' with `-' (or any other character) in place of the `c'

details |

copy
80
15
tr -d axMDeleting a small set of characters is usually straightforward. For example, to remove all `a's, `x's, and `M's you would do this

details |

copy
72
11
tr a-z A-ZConvert lowercase characters to uppercase

details |

copy
58
16
tr -d '\0'Remove all zero bytes

details |

copy
64
12
tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZA common use of `tr' is to convert lowercase characters to uppercase

details |

copy
70
29
tr -cs '[:alnum:]' '[\n*]'Pad the first set to the size of the second set

details |

copy
47
11
tr -d axM-we might try `tr -d -axM', but that would fail because `tr' would try to interpret `-a' as a command-line option. Alternatively, we could try putting the hyphen inside the string, `tr -d a-xM', but that wouldn't work either because it would make `tr' interpret `a-x' as the range of characters `a'...`x' rather than the three. One way to solve the problem is to put the hyphen at the end of the list of characters

details |

copy
41
12
tr -d -- -axMyou can use `--' to terminate option processing:

details |

copy
86
21
tr -cs '[:alnum:]' '[\n*]'Put all words on lines by themselves. This converts all non-alphanumeric characters to newlines, then squeezes each string of repeated newlines into a single newline

details |