Преобразование регистра строки

uppercase convert case sed

For example, if I have:

a="Hi all"
I want to convert it to:
"hi all"

tr

$ echo "$a" | tr '\[:upper:\]' '\[:lower:\]'
hi all

AWK

$ echo "$a" | awk '{print tolower\($0\)}'
hi all

Bash 4.0

$ echo "${a,,}"

sed

$ echo "$a" | sed -e 's/\(.*\)/\L\1/'

Perl

$ echo "$a" | perl -ne 'print lc'

Bash

lc(){
    case "$1" in
        [A-Z])
        n=$(printf "%d" "'$1")
        n=$((n+32))
        printf \\$(printf "%o" "$n")
        ;;
        *)
        printf "%s" "$1"
        ;;
    esac}
word="I Love Bash"for((i=0;i<${#word};i++))do
    ch="${word:$i:1}"
    lc "$ch"done

Примеры на SO