So I was searching around and using the command tr
you can convert from lower case to upper case and vice versa. But is there a way to do this both at once?
So:
$ tr '[:upper:]' '[:lower:]' or $ tr A-Z a-z
Will turn "Hello World ABC" to "hello world abc", but what I want is "hELLO wORLD abc".
You can use `tr` command in the following way also to convert any string from lowercase to uppercase. Run the following command to convert all small letters of the string,'linuxhint' into the capital letter. Output: The following output will appear after executing the above command.
How do I convert uppercase words or strings to a lowercase or vise versa on Unix-like / Linux bash shell? Use the tr command to convert all incoming text / words / variable data from upper to lower case or vise versa (translate all uppercase characters to lowercase).
1. A simple tr command use case is to change all lower case letters in text to upper case and vice versa, as shown below. $ cat linux.
The ^ operator converts to uppercase, while , converts to lowercase. If you double-up the operators, ie, ^^ or ,, , it applies to the whole string; otherwise, it applies only to the first letter (that isn't absolutely correct - see "Advanced Usage" below - but for most uses, it's an adequate description).
This will do what you are looking for:
tr '[:upper:][:lower:]' '[:lower:][:upper:]'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With