Skip to main content
typo
Source Link
meuh
  • 54.7k
  • 2
  • 70
  • 139

Use awk to match the line and split it into words separated by ( or ). Take the 2nd word $2, or preferably the next-to-last $(NF-1) if you might have parentheses in the device name:

awk -F '[()]' '/Mouse/{print $($NFNF-1)}' 

Use awk to match the line and split it into words separated by ( or ). Take the 2nd word $2, or preferably the next-to-last $(NF-1) if you might have parentheses in the device name:

awk -F '[()]' '/Mouse/{print $($NF-1)}' 

Use awk to match the line and split it into words separated by ( or ). Take the 2nd word $2, or preferably the next-to-last $(NF-1) if you might have parentheses in the device name:

awk -F '[()]' '/Mouse/{print $(NF-1)}' 
you might have parentheses in the device name
Source Link
meuh
  • 54.7k
  • 2
  • 70
  • 139

Use awk to match the line and split it into words separated by ( or ). Take the 2nd word $2, or preferably the next-to-last $(NF-1) if you might have parentheses in the device name:

awk -F '[()]' '/Mouse/{print $2$($NF-1)}' 

Use awk to match the line and split it into words separated by ( or ). Take the 2nd word:

awk -F '[()]' '/Mouse/{print $2}' 

Use awk to match the line and split it into words separated by ( or ). Take the 2nd word $2, or preferably the next-to-last $(NF-1) if you might have parentheses in the device name:

awk -F '[()]' '/Mouse/{print $($NF-1)}' 
Source Link
meuh
  • 54.7k
  • 2
  • 70
  • 139

Use awk to match the line and split it into words separated by ( or ). Take the 2nd word:

awk -F '[()]' '/Mouse/{print $2}'