0

I am writing a small Android program that can check how many files contains a certain string without reading completely their contents Therefore, I've found a good way to do it is using grep -q command. Because of executing the command doesn't output but a exit code (0 : match, 1 : not match)

However I have no idea that how to get the exit code after executing the command completed by C language in JNI.

fedorqui
  • 275,237
  • 103
  • 548
  • 598
Long Uni
  • 101
  • 3
  • 12
  • http://stackoverflow.com/questions/478898/how-to-execute-a-command-and-get-output-of-command-within-c – Blackbelt Apr 09 '15 at 13:20
  • Thanks Blackbelt for your reference. In my case, execute "grep -q" is without output. It can only checked if completed by the exit code echo $? Do you have any idea else? – Long Uni Apr 09 '15 at 13:28
  • All -q does is suppress the normal output of grep. Just don't use that option, and use the technique described in the given link. – Andrew Fielden Apr 09 '15 at 15:07
  • I decided to use -q due to I don't want to read the whole files which are mostly large. – Long Uni Apr 10 '15 at 13:28

0 Answers0