For updating my system I have the following alias:
alias up="flatpak update -y & sudo dnf upgrade -y"
I deliberately chose &
instead of &&
to update both in parallel and save time.
The problem is that the terminal output is not useable because the two processes override each other's output.
Is it possible for one of the commands to hold back its output until the first one is finished?
CodePudding user response:
It's a little more complicated than I thought. For making sure that the output of dnf
is printed after the output of flatpak
, you'll have to save the former AND wait for the latter to complete:
flatpak update -y 2>&1 | { cat & pid=$!; out=$(sudo dnf upgrade -y 2>&1); wait "$pid"; printf '%s\n' "$out"; }
CodePudding user response:
If you have GUNU parallel
installed, you can do :
alias up="printf '%s\n' 'flatpak update -y' 'sudo dnf upgrade -y' | parallel"