That is why you need to use PRODUCT environmental variable to identify which device has been disconnected. Note that when the device is disconnected from the USB bus, some udev environmental variables are not available ( ID_VENDOR_ID or ID_MODEL_ID),
#!/bin/bash # Abort script execution on errors set - e if [ '$ ' / dev / stdin END exit 0