- Linux Shell Scripting Cookbook(Third Edition)
- Clif Flynt Sarath Lakshman Shantanu Tushar
- 132字
- 2021-07-09 19:46:17
How to do it...
To perform translation of characters in the input from uppercase to lowercase, use this command:
$ echo "HELLO WHO IS THIS" | tr 'A-Z' 'a-z' hello who is this
The 'A-Z' and 'a-z' are the sets. We can specify custom sets as needed by appending characters or character classes.
The 'ABD-}', 'aA.,', 'a-ce-x', 'a-c0-9', and so on are valid sets. We can define sets easily. Instead of writing continuous character sequences, we can use the 'startchar-endchar' format. It can also be combined with any other characters or character classes. If startchar-endchar is not a valid continuous character sequence, they are then taken as a set of three characters (for example, startchar, -, and endchar). You can also use special characters such as '\t', '\n', or any ASCII characters.