@Aristarchus, to avoid all errors, I agree. However, that is not the question.
I want to filter out the errors and only return the output for which I do have permissions.
like this:
kernel.shm_next_id -1
kernel.shm_rmid_forced 0
kernel.shmall 1073741824
<cut>