view bin/ff @ 4:1641fdbc1809 default tip

sic
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Tue, 18 Aug 2026 15:39:39 +0100
parents 2aa53823fb21
children
line wrap: on
line source

#!/bin/sh
# find any match from here
if [ "$1" = "-d" ]
then
 shift
 d="$1"
 shift
else
 d=.
fi
if [ "$1" = "-L" ]
then
 shift
 ll=-L
else
 ll=
fi
if [ "$1" = "-y" ]
then
 shift
 yy=
else
 yy="-not ( -path ./Yesterday -prune )"
fi
if [ "$1" = "-0" ]
then
 shift
 p=print0
else
 p=print
fi
usage="Usage: ff [-d where] [-L] [-y] [-0] pat ...\nfind pat anywhere in any name and print it\n -L follow links\n -y do look in Yesterday\n -0 use print0\n Anything after pat is included _before_ the final print(0)\n"
if [ "$1" = "-?" ]
then
 printf "$usage"
 exit 0
fi
if [ "${1:0:1}" = "-" ]
then
 printf "Additional args must be _after_ the pattern\n"
 printf "$usage" 1>&2
 exit 1
fi
ff=$1
shift
find $ll "$d" $yy \( \( -iname \*$ff\* \) -o \( -iname .\*$ff\* \) \) "$@" -$p