#!/bin/bash variable=$( echo "moo" nosuchcommand || echo "this did not work out so well" nosuchcommand_either ls -l /usr/share/words >&2 echo "*** bar ***") echo "$variable"
Standard input is empty
moo this did not work out so well *** bar ***
./prog.sh: line 10: nosuchcommand: command not found ./prog.sh: line 11: nosuchcommand_either: command not found ls: cannot access /usr/share/words: No such file or directory