I want to check if a USB is busy and store the result in a variable:
$ foo=$(umount /dev/sdb1) $ umount: /path/mounted: target is busy.
But when I want to print
$foo, I get an empty variable
$ echo $foo $
My final goal is to umount the USB. If the target is busy, issue a warning to the user, using
$ [[ -z $foo ]] || whiptail --msbox "Cancel the operation that is maintaining your USB busy" 0 0
Is it possible to store the error
target is busy on a variable, or should I use another kind of technique?