2 #From: kaz@cafe.net (Kaz Kylheku)
3 #Newsgroups: comp.unix.shell
4 #Subject: Why not roll your own @#$% find! (was: splitting directory off from filename)
5 #Message-ID: <6n1117$tp1@espresso.cafe.net>
6 #Date: Fri, 26 Jun 1998 20:47:34 GMT
8 # $1 = dirname, $2 = pattern, optional $3 = action
14 # descend into specified directory
16 builtin cd -L "$1" ||
{
17 echo "${FUNCNAME}: cannot change dir to $1" >&2
22 # default action is to print the filename
27 action
='printf -- "%s\n"'
30 # process ordinary files that match pattern
38 # now descend into subdirectories, avoiding symbolic links
39 # and directories that start with a period.
42 if [ -d "$x" ] && [ ! -L "$x" ] ; then
43 $FUNCNAME "$x" "$2" "$action"
47 # finally, pop back up