finding the filesystem of a file

Chris Preston cbp at icc.com
Sat Nov 10 10:05:18 AEST 1990


In article <1990Nov06.021023.11941 at virtech.uucp> cpcahil at virtech.UUCP (Conor P. Cahill) writes:
>In article <6495 at emory.mathcs.emory.edu> dt at mathcs.emory.edu (Dave Taylor {guest}) writes:
>>Curious to know if anyone can tell me the fastest way to find out which
>>filesystem a given file is on if the entire pathname is given.  I have only
>
>Maybe not the fastest, but it will work:
[shell script deleted]
or an awk solution

mount | 
awk 'BEGIN{
# file is defined so as to minimize confusion by useing $1 in substr()
# also, I believe that this should be $3 in Xenixland
	file="'$1'"
	if ( file == "" ){
		print "Usage: '$0' <filename>"
		exit
	}
}
{
	lenfsnam=length($1)
	if ( $1 == substr(file,0,lenfsnam) ){
		list[lenfsnam]=$1
		if ( lenfsnam > closematch )
			closematch=lenfsnam
	}
}
END{ 
	if ( closematch )
		print list[closematch]
	else
#totally optional - should take out if meant for pipe usage
		print "no match"
}' 

cbp
---
Kurt Waldheim to Saddam Hussein:
"Saddam, I knew Hitler, and believe me, you're no Adolf Hitler."



More information about the Comp.unix.shell mailing list