I have a bash script that runs a bunch of other commands (e.g. docker). I want the script to be able to capture all the output into a variable and then echo out a custom return at the end.
Example:
#!/usr/bin/env bash
set -euo pipefail
# Capture into this (PSEUDO CODE)
declare CapturedOutput
$(Capture Output > CapturedOutput)
# Run some commands like...
docker-compose ... up -d
# Stop capturing (PSEUDO CODE)
$(Stop Capture Output > CapturedOutput)
echo "something"
So if someone called my script like ./runit.sh
and the docker command had output, they wouldn't see it but would only see:
> ./runit.sh
something