I want to write a shell script, which will run fdisk -l and extract a string /dev/sdbn from the output of fdisk -l.Using extracted word I want to mount it to /mnt.For Example:Disk identifier: 0x00000000Device     Boot    Start    End    Blocks    Id    System/dev/sdb1    *         1    493    3956672    6     FAT16How do I only extract the string /dev/sdb1?
Extracting a string from fdisk command
shell script;fdisk
Try:fdisk -l | grep -o '^/dev/sdb[0-9]'The -o option causes grep to print only matching pattern.UpdatedIf you want all except /dev/sdaX, you can use:fdisk -l | grep -o '^/dev/sd[b-z][0-9]'