aboutsummaryrefslogtreecommitdiff
path: root/find
blob: 0039a12e454a31b3afcd24b7140b1d2ba6ce3fe8 (plain)
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
#!/bin/bash
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() {
  [[ $# < 2 ]] && usage
  name=$1; shift
  address=$1; shift
  if [[ $# == 0 ]]; then
    find_single $name $address
  else
    comm -12 \
      <(find_single $name $address) \
      <(find "$@")
  fi
}

for id in `find "$@"`; do
  echo "`cat db/${id}.info` (id $id)"
done