I'm trying to write a script in bash that will carve a file out of another file.
I'm kind of stuck, though, because I have no idea how to do this next part.
I need to get a hex value of a line in a file and then use the bc command (binary calculator I assume
) to convert that to decimal.
This is what I have so far.
This gives me the 7 digit hex value and it's saved as $start.
What I need to do now is put that through the second command which is:
How do I put the variable where [hexvalue] is, because the " " seem to be necessary in the code :S I've tried things like below but I just can't seem to get it to work. I can't find anything online that helps with it and my knowledge of bash is very very very basic
I have put the code as
and now the result comes up as (standard_in) 1: parse error.
Does anyone have any idea how I could get the 7 digit variable to work in the code I have?
Thanks
I'm kind of stuck, though, because I have no idea how to do this next part.
I need to get a hex value of a line in a file and then use the bc command (binary calculator I assume

This is what I have so far.
Code:
start=$(awk '/: / {print $1}' temp | head -c 7)
This gives me the 7 digit hex value and it's saved as $start.
What I need to do now is put that through the second command which is:
Code:
echo "ibase=16;[hexvalue]" | bc
How do I put the variable where [hexvalue] is, because the " " seem to be necessary in the code :S I've tried things like below but I just can't seem to get it to work. I can't find anything online that helps with it and my knowledge of bash is very very very basic

Code:
echo "ibase=16;`$start`" | bc
I have put the code as
Code:
echo "ibase=16; $start" | bc
and now the result comes up as (standard_in) 1: parse error.
Does anyone have any idea how I could get the 7 digit variable to work in the code I have?
Thanks
Last edited: