Displaying octal numbers in bash

Joel Hammer Joel
Mon May 17 11:54:04 PDT 2004


This seems more work that it should be.

I did solve my problem with bc, but, there must be an easy way to get
bash to display octal.

Joel
On Wed, Sep 24, 2003 at 06:35:18PM -0700, Tom Wekell wrote:
> 
> 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
> 


More information about the Linux-users mailing list