In this article I will provide you the code to reverse each character case in a string using bash script. Convert from uppercase to lowercase and vice versa. This code works on each character. For example – hElLo will get converted to HeLlO.
Code Example –
#!/bin/bash reverse_case() { echo "${1~~}" } reverse_case "AN animAl is aN animal. DONKEY or DOG does NoT mAtTeR" # Output # an ANIMaL IS An ANIMAL. donkey OR dog DOES nOt MaTtEr