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

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

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

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

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

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