Linux commands to change the text cases and number systems
conversion of text format
codeaft@codeaft:~$ echo 'Hello, World!' | tr "[:lower:]" "[:upper:]"
HELLO, WORLD!

codeaft@codeaft:~$ echo 'HeLLo, WORLD!' | tr "[:upper:]" "[:lower:]"
hello, world!

codeaft@codeaft:~$ typeset -l lcase codeaft@codeaft:~$ lcase="Hello, World!" codeaft@codeaft:~$ echo $lcase hello, world! codeaft@codeaft:~$ typeset -u ucase codeaft@codeaft:~$ ucase="Hello, World!" codeaft@codeaft:~$ echo $ucase HELLO, WORLD!
codeaft@codeaft:~$ s1="HeLLo, WORLD!" codeaft@codeaft:~$ echo $s1 HeLLo, WORLD! codeaft@codeaft:~$ echo ${s1,,} hello, world! codeaft@codeaft:~$ echo ${s1^^} HELLO, WORLD!
conversion of number systems
codeaft@codeaft:~$ printf "Octal of 65535 = %o\n" 65535
Octal of 65535 = 177777

codeaft@codeaft:~$ printf "Hexadecimal of 65535 = %x\n" 65535
Hexadecimal of 65535 = ffff

codeaft@codeaft:~$ printf "Floating point in 65535 = %f\n" 65535
Floating point in 65535 = 65535.000000

codeaft@codeaft:~$ D2B=({0..1}{0..1}{0..1}{0..1}{0..1}{0..1}{0..1}{0..1}) codeaft@codeaft:~$ echo "Binary of 255 = "${D2B[255]} Binary of 255 = 11111111 codeaft@codeaft:~$ echo "Decimal of 01AE = "$((0x01AE)) Decimal of 01AE = 430 codeaft@codeaft:~$ echo "Decimal of 11111111 = "$((2#11111111)) Decimal of 11111111 = 255 codeaft@codeaft:~$ echo "obase=2;255" | bc 11111111 codeaft@codeaft:~$ echo "ibase=2;11111111" | bc 255 codeaft@codeaft:~$ echo "obase=7;255" | bc 513 codeaft@codeaft:~$ echo "obase=16;255" | bc FF codeaft@codeaft:~$
Comments and Reactions