#Identify links to a file
#Usage: lnks file [directory]
if [ $# -eq 0 -o $# -gt 2 ] ;
then
echo "Usage; lnks file [directory]" 1>&2
exit
fi
then
echo "First argument cannot be a directory." 1>&2
echo "Usage: lnks file [directory]" 1>&2
exit
else
file="$1"
fi
then
directory="."
elif [ -d $2 ] ;
then
directory="$2"
else
echo "Optional second argument must be a directory." 1>&2
echo "Usage:lnks file [directory]" 1>&2
exit
fi
then
echo "lnks: $file not found or special file" 1>&2
exit
fi
linkcnt=$2
if [ "$linkcnt" -eq 1 ];
then
echo "Lnks: no other hard links to $file" 1>&2
exit
fi
inode=$1
echo "lnks:using find to search for links..." 1>&2
find "$directory" -xdev -inum $inode -print