Grep mpath disk name from lsblk command

When I use

 lsblk | tail -1 | awk -F " " '{print $1}'

command and if a disk is a multipath I get output as

└─mpathe 

But i need only mpathe to be grepped as output.. Please help.. But It works well if the disk is not mpath

Well, there are better ways do to this, but for fun:

lsblk | tail -1 | sed 's/└─//'| awk -F " " '{print $1}'

You can see this chars in bash:

bash# for i in 6a 6b 6c 6d 6e 71 74 75 76 77 78; do printf "\x1b(0\x$i\x1b(B\n\n"; done
┘

�

┌

└

┼

─

├

┤

┴

┬

│

I would do this another way (I prefer to filter text with PHP), but this is a gentle reminder that there is a char (maybe 2) you need to filter out.

How you filter that, is up to you.

If you are bent on using awk, filter with awk.

How about

lsblk -r -oname

? From man lsblk :

1 Like