-
Notifications
You must be signed in to change notification settings - Fork 0
/
ff
executable file
·68 lines (62 loc) · 1.05 KB
/
ff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
#set -x
DIRS=""
PATTS=""
OTHER=""
NAME="-name"
for arg in $*;
do
C=${arg:0:1}
case $C in
/|.)
DIRS="$DIRS $arg"
;;
-)
case $arg in
-h)
echo "ff - fast find"
echo
echo "Usage: ff [-i] [-d] [-l] [directory] pattern"
echo
echo "An argument starting with / or . is interpreted as a directory, otherwise as a pattern."
echo "Directory defaults to the current directory. @ characters in pattern are replaced with *."
echo
echo "Options:"
echo
echo "-i | Case insensitive"
echo "-d | Find directories instead of files"
echo "-l | Find symlinks instead of files"
echo
exit 1
;;
-d)
OTHER="$OTHER -type d"
;;
-l)
OTHER="$OTHER -type l"
;;
-i)
NAME="-iname"
;;
esac
;;
*)
arg=${arg//@/\*}
PATTS="$PATTS $arg"
;;
esac
done
if [[ -z $PATTS ]];
then
PATTS="*"
fi
if [[ -z $DIRS ]];
then
DIRS="."
fi
set -f
for dir in $DIRS; do
for patt in $PATTS; do
find $dir $OTHER $NAME $patt
done
done