I need to filter the result of this command:
lsblk -rno "name,size,mountpoint,fstype" | grep -v 'sda'
Let me give a result of the above command on my computer:
sdb 223,6G
sdb1 179,8G /VMs/qemu ext4
sdb2 29,5G [SWAP] swap
sdc 15G ntfs
sdd 7,5G
sdd1 7,5G ext4
The filtering I need is: Only the ones which are NOT mounted and the ones which have file system to be left. So ideally what would be left after filtering should be:
sdc 15G ntfs
sdd1 7,5G ext4
My goal is to have a script (which can be called using rofi of dmenu) to mount usb drives. I've fould solutions on the net, but the problem with these is that they assume that all drives have partitions. As you see, I use external drives formatted without being partitioned first (the ntfs for example). So I need this change.
lsblk
withgrep
. It sounds like what you want is "a list of partitions, other than for/dev/sda
, that are not mounted but that contain a filesystem"?