3

With Radare2, I love the iI command.

I want to limit the output with grep or radare's own grep syntax.

How do I run a iI | grep -E 'bits | pic | stripped' against my binary?

[0x100001200]> iI
arch     x86
binsz    38688
bintype  mach0
bits     64
....
..
.

My intention is to run this command inside a python script using r2pipe.

1 Answer 1

6

Radare's grep is done by using the ~ character.

 ~?<br>
|Usage: [command]~[modifier][word,word][endmodifier][[column]][:line]

So to have the output you want just run:

iI~bits,pic,stripped

[0x100001200]> iI~bits,pic,stripped
bits     64
pic      true
stripped true

The same command you should run in your script. There's a lot of more that this grep can do. To get the help of it just run the ~?

3
  • Thanks. Just what I was looking for. Next I will try and work out why the json flag + grep instruction doesn't work with: iIj~bits,pic,stripped. But I can do that solo. Thanks again. Jul 25, 2018 at 7:17
  • 1
    json supports a limited grep in a form: iIj~{bits} but you would have to grep for the three things separately. Jul 25, 2018 at 14:59
  • That actually gives me a better answer. I can now use iIj~{stripped} as it return the value (true / false) instead of the Key Value Pair you get with iI~stripped (stripped true) Jul 26, 2018 at 6:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.