List all usb drives connected

Hi guys, ok on a completely different note from my last question i was wondering if you may be able to assist me yet again.

I'm trying to list all usb drives connected to my pc.

here's what i have so far.

#!/bin/bash
drives=$("lsblk --nodeps --paths --output NAME,TRAN | grep usb | awk '{print $1}'")
kdialog --msgbox "$drives"

am i even close? I know it'll work on gambas but i would REALLY prefer to run it as script.

ok i worked it out. For anyone with a similar question here's what worked for me:

#!/bin/bash

answer=$(kdialog --combobox "Select USB Device" $(lsblk --nodeps --paths --output NAME,TRAN | grep usb | awk '{print $1}'))

kdialog --msgbox "$answer"

on a completely unrelated not, can anyone tell me how to use blockquotes???

Put your code between
```
lines.

Or click on the "terminal" icon on the top of the editor window. Either before typing your code, or after marking the code.

Improvement: look for the usb in the TRAN column only.

lsblk --nodeps --paths --output NAME,TRAN | awk '$2 ~ /usb/ {print $1}'
1 Like