Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!sdrc!cinnet!icc!cbp From: cbp@icc.com (Chris Preston) Newsgroups: comp.unix.shell Subject: Re: finding the filesystem of a file Keywords: filesystem search find file Message-ID: <1990Nov9.230518.12342@icc.com> Date: 9 Nov 90 23:05:18 GMT References: <6495@emory.mathcs.emory.edu> <1990Nov06.021023.11941@virtech.uucp> Distribution: usa Organization: Intercomputer Communications Corp., Cincinnati, OH Lines: 39 In article <1990Nov06.021023.11941@virtech.uucp> cpcahil@virtech.UUCP (Conor P. Cahill) writes: >In article <6495@emory.mathcs.emory.edu> dt@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' " 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."