Skip to main content
1 of 2
Mark Plotnick
  • 26.1k
  • 3
  • 68
  • 82

It can be somewhat messy if the mount points contain blanks, but this should work except in cases where the mount points contain newlines:

#!/bin/sh mountpoint="$(df -P $1 | awk '{ if (NR==1) i=index($0,"Mounted on"); else print substr($0,i); }')" mount|grep " on ${mountpoint} type " 

df -P outputs one line for the filesystem; without that option, df may output two lines if the mount point is long. The mount point name starts in the same column as does the "Mounted on" label in the header line.

After we get the mount point, we grep for it in the output of mount.

Mark Plotnick
  • 26.1k
  • 3
  • 68
  • 82