The pipe operator |
is interpreted the shell so does not form part of the command itself. In addition the command needs to appear in a single token to prevent the grep segment being evaluated separately:
String cmd[] = { "bash", "-c", "ifconfig |grep 'inet addr:'" };