Other Testing for presence of USB device

At most you'd be able to test(1) for the existence of the device file. But you need to know the device in advance. [ -c /dev/da0] for example. And the "USB device" needs to create a /dev/ device node, certainly not all "USB devices" do. Are you testing for a specific type of USB device? If it's any random type of "USB device" then usbconfig(8) is your best bet.
 
I'm just trying to write something to a USB stick.

This seems to do what I want.

sh:
if ! usbconfig | grep 'DISK USB' ; then                                                                                                                                                                                                                                   
     echo 'no usb disk attached, please insert'                                                                                                                                                                                                                               
exit
 
Back
Top