How do I convert from octal to hex number using bc UNIX / Linux command line utility?
The octal numeral system is a base 8 numeral system. It uses the numerals 0 through 7. You need to use the following bc syntax to covert number:
echo "obase=16; ibase=8; octal-number-here" | bc echo "obase=16; ibase=8; 17" | bc
Sample outputs:
F
You need to set obase before ibase; otherwise you may get unexpected results:
echo "obase=16; ibase=8; 054253" | bc
Sample outputs:
58AB
This is wrong (yes, bc isn't smart enough to figure this out on its own; so make sure you set obase before ibase):
echo "ibase=8; obase=16; 054253" | bc
Sample outputs:
83B5
Printf command example
You can also use the printf command as follows:
$ printf "%x\n" 0306
Sample output:
c6
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop








![Linux Copy File Command [ cp Command Examples ]](http://s0.cyberciti.org/images/rp/1/27.jpg)



{ 0 comments… add one now }