RHEL/Centos7 Shell tips: bc/printf
1. BC
[email protected]:~/tmp$ bc
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
ibase <<<<<<<< default dec for input
10
obase <<<<<<<< default dec for output
10
ibase=16 <<< change input to hex
obase=2 <<< change output to binary
55 <<<< input 0x55/hex mode
1010101 <<<< output of binary for input 0x55
2. printf
[email protected]:~/tmp$ which printf
/usr/bin/printf
[email protected]:~/tmp$ file /usr/bin/printf
/usr/bin/printf: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=318c48d6d29df539048faaeb48cb65c98722d0e4, stripped
[email protected]:~/tmp$ printf "%d\n" "'3'"
51