How to detect NTFS/exFAT filing system type fronm script
Thanks to the other posters for replying/suggesting. Here is my full solution.
df -P
can be used to obtain device from path, and that can be fed to lsblk --fs
to obtain exact file system. So a one-liner is:
fs=$( lsblk --fs --noheadings $( df -P $path | awk 'END{print $1}' ) | awk 'END{print $2}' )
If all you need to know is that the file system is fuseblk
--- which covers both ntfs
& exfat
and turns out in the end to be sufficient for my purposes after all --- this can be determined with the much simpler:
fs=$( stat -f -c '%T' $path )
I'm not sure I follow your question completely, so I'll offer this as a "point of departure". If it gets you close, I'm sure you can tweak it to get what you need:
$ lsblk --fs | grep / | awk '{print $1, $2}'
what about df .
and mount
?
first let's get mount point
cd /a/dir
mp=$(df . | awk 'NR==2 { print $1}')
$mp
while hold device name hoding/a/dir
now, mount point
mount | awk -v mp=$mp '$1 == mp { print $5}'
this should return mount type (be it xfs
, etx3
, ...)
edit:
- I see my answer is covered in one of the link, you might whish to explore line returned by mount, not just
$5