Reputation: 83
When executing
sudo fdisk -l | tail -n 1
the result gives me
/dev/sdb1 * 8064 7669823 3830880 b W95 FAT32
So what I need is to extract just "/dev/sdb1/". Not exactly just sdb1, whatever device that is listed last. What if I have two flash drives and I need the last one?
I've searching everywhere and I couldn't find how. Thanks in advance.
Upvotes: 0
Views: 180
Reputation: 26677
sudo fdisk -l | tail -n 1 | awk '{print $1}'
will produce as
/dev/sdb1
Upvotes: 1