#!/bin/bash arg0=$(basename $0) if [ $# -gt 1 ] then echo "Usage: $arg0 " exit 1 fi export IFS="" # Get a list of files matching the pattern from both locate and mdfind. # Run the list through sort to eliminate duplicates. # Then filter it for files that still exist, since locate databases # are only updated nightly/weekly by cron depending on configuration. (mdfind "kMDItemFSName = *$1*" ; locate "$1") | sort -u | while read name do # Use -a for Korn shell [ -e "$name" ] && echo "$name" done exit 0