Quote:
Originally Posted by mcfc1900
variable=$(ibase=16; $hex | bc)
|
I can't see how you expect that to work. Assuming
$hex holds a valid hexadecimal value,
ibase=16; $hex needs to be supplied to
bc on its standard input. The
| (pipe) implies that some other program will be emitting the program from its standard output.
This works fine for me.
Code:
foo$ hex=10
foo$ variable=$(echo "ibase=16; $hex" | bc)
foo$ echo $variable
16
foo$
I think we will need to see more of your program to determine the cause of your error.
Edit
Quote:
Originally Posted by Kenhelm
The error message could be caused by the letters in $hex not being in upper case.
Lower case letters are used for variable names in bc.
|
Nice catch!