forked from niklasb/libc-database
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfind
More file actions
executable file
·35 lines (32 loc) · 652 Bytes
/
find
File metadata and controls
executable file
·35 lines (32 loc) · 652 Bytes
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
#!/bin/bash
cd "$(dirname "$0")"
function usage() {
echo >&2 "Usage: $0 name address [name address ...]"
exit 2
}
function find_single() {
name=$1
address=$2
addr_last12=`echo -n "$address" | tail -c 3`
grep -i -e "^$name .*$addr_last12$" db/*.symbols \
| perl -n -e '/db\/(.*)\.symbols/ && print "$1\n"' \
| sort
}
function find() {
[[ $# -lt 2 ]] && usage
name=$1; shift
address=$1; shift
if [[ $# == 0 ]]; then
find_single $name $address
else
comm -12 \
<(find_single $name $address) \
<(find "$@")
fi
}
ret=1
for id in `find "$@"`; do
echo "`cat db/${id}.info` ($id)"
ret=0
done
exit $ret