Bash BC problem
My line of code which isn't working is the following:
variable=$(ibase=16; $hex | bc) I have also tried: variable=$(echo "ibase=16; $hex" | bc) Neither will work and gives me the error "(Standard_in) 1: parse error". $hex has been defined two lines above this piece of code... Can anyone see where I am going wrong please? Thanks |
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. Code:
hex=45de |
Quote:
This works fine for me. Code:
foo$ hex=10 Edit Quote:
|
Thank you both :)
The problem was that the hex value was lower case, soon as I changed that it started working. Cheers |
Quote:
Code:
variable=$[0x$hex] |
All times are GMT -5. The time now is 12:56 PM. |