As mentioned a few times before there is an ability to sequence commands using semicolon operator.
It simply runs the second command after finishing the first one, like in a shell.
The second important way to sequence the commands is with a simple pipe |
ao|grep address
For example, we want to see a few bytes of the memory at the address referred to by the ‘mov eax, addr’ instruction. We can do that without jumping to it, using a sequence of commands:
And of course it’s possible to redirect the output of an r2 command into a file, using the >
and >>
commands
[0x00404800]> px 10 @ `ao~ptr[1]` > example.txt
[0x00404800]> px 10 @ `ao~ptr[1]` >> example.txt
Radare2 also provides quite a few Unix type file processing commands like head, tail, cat, grep and many more. One such command is , which can be used to filter a file to display only non-duplicate content. So to make a new file with only unique strings, you can do:
1 Protein
3 Fat
[0x00404800]> tail 2 foodtypes.txt
3 Shake
4 Milk
The join command could be used to merge two different files with common first field.
Similarly, sorting the content is also possible with the command. A typical example could be:
[0x00404800]> sort file
five
great
one
one
The ?$?
command describes several helpful variables you can use to do similar actions even more easily, like the $v
“immediate value” variable, or the $m
opcode memory reference variable.