Remove unused variables in shell scripts. Use _ where we don't care about the result.
Backport of core PR10771 and PR11649
https://github.com/bitcoin/bitcoin/pull/10771/files
https://github.com/bitcoin/bitcoin/pull/11649/files
Depends on D3955.
Not much change remaining as most of the files have been removed.