The below script is used to open an Android emulator and install an react native app on it. I would like to hide the output of the emulator in the terminal so the next command can be read instead of the output of the emulator. How can I do that?
read -p "Which Android emulator name (i.e. Pixel_7_Pro_API_34)?: " device
emulator -avd $device &
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done; input keyevent 82'
npx react-native run-android
Mike!
this can be achieved by redirecting the output of the command to /dev/null
by using:
emulator -avd $device &> /dev/null
explanation: 1> /dev/null
redirects stdout
to /dev/null
and 2> /dev/null
redirects stderr
to /dev/null
. using &> /dev/null
redirects both. 1 is stdout
. 2 is stderr
.
PS: you can also use 2>& 1
to to redirect stderr
to stdout
.