#!/bin/sh #\- search along PATH for files (wildcards expanded), and display full path or long ls listing (-l), or search for setuid files (-s) #usage: %paths [-ls] 'filelist' #(use single quotes around filelist if needed to protect "*" #against globbing by the working directory) #print directory location of a file, or the file's long dir listing, #or search for setuid files along PATH #much slower than every/which, but a major advantage = #can use filename expansion to get all globbed files in all PATH dirs #sage, "tricks of the unix masters", sams, 1987, p 42ff #modified by j.a. rupley, tucson, az FORMAT="path" if [ "x$1" != "x" ] then case $1 in -l) FORMAT="ls";shift;; -s) FORMAT="set";set "1";; -*) /bin/echo "usage $0 [-l] [-s] [filelist]" exit 1;; esac fi XPATH="`/bin/echo $PATH | /usr/bin/sed 's/.://'`" IFS="${IFS}:" for DIR in $XPATH do if [ -d $DIR ] then cd $DIR else continue fi for FILE in $@ do case $FORMAT in path) if [ -f $DIR/$FILE ] then /bin/echo "$DIR/$FILE" fi;; ls) if [ -f $DIR/$FILE ] then /bin/ls -l $DIR/$FILE fi;; set) echo "\n::::::::::::::::::" echo "$DIR" echo "\n::::::::::::::::::" /bin/ls -al $DIR | /usr/bin/grep "^[^ ]*s[^ ]*";; esac done done