Displaying octal numbers in bash

Tom Wekell Tom
Mon May 17 11:54:04 PDT 2004


Joel Hammer wrote:
> I understand that bash will do arithmetic in octal if you prefix the
> constant with 0. So:
> a=05
> b=017
> c=$((a*b))
> echo $c
> yields
> 75
> This is the correct answer, but it is in decimals, not octals.
> Is there a way to make echo display octal?
> Thanks, 
> Joel
> 

More arithmetic?

echo $((8#$c*1)) gives 61

Tom Wekell



More information about the Linux-users mailing list