On Thu, Jul 05, 2007 at 05:58:18AM +0200, Stefan Reinauer wrote:
- Uwe Hermann uwe@hermann-uwe.de [070704 19:47]:
I use some aliases in my .bashrc which are pretty handy for converting HEX or BINARY or DECIMAL:
alias HEX="ruby -e 'printf("0x%X\n", ARGV[0])'" alias DEC="ruby -e 'printf("%d\n", ARGV[0])'" alias BIN="ruby -e 'printf("%bb\n", ARGV[0])'"
Usage:
$ HEX 78 0x4E $ BIN 0x6a 1101010b $ DEC 0x72 114
cool stuff. Can it easily be fixed to convert binary into hex or dec, too?
Yes, that works already (the syntax is a bit strange, though):
$ HEX 0b10101010 0xAA $ DEC 0b10000011 131
Uwe.