1

I parsed /proc/PID/maps using shell script , now I have 2 variable

START_ADDR=982fe000
END_ADDR=984fe000

I want to use those variable for dd using shell script command like:

dd if=SOME_MEMORY skip=START_ADDR count=(END_ADDR-START_ADDR) of=out.bin bs=1

How can I convert those variable for dd?

Kokomelom
  • 143
  • 1
  • 10
  • Does this answer your question? [Hexadecimal To Decimal in Shell Script](https://stackoverflow.com/questions/13280131/hexadecimal-to-decimal-in-shell-script) – Iłya Bursov Jan 06 '23 at 05:26

1 Answers1

2

As you didn't mention which shell you are using, I am assuming you are using bash.
Keeping that in mind, you can modify your above command as shown below to make it work.

dd if=$SOME_MEMORY skip=$START_ADDR count=$((0x$END_ADDR - 0x$START_ADDR)) of=out.bin bs=1

You need to make sure the variables SOME_MEMORY, END_ADDR and START_ADDR are accessible and present in current shell environment, to verify you can do
echo $SOME_MEMORY, echo $START_ADDR and similarly echo $END_ADDR

Gaurav Pathak
  • 1,065
  • 11
  • 28