proving git release script isn't busted
[feisty_meow.git] / scripts / archival / search_arch.sh
1 #!/bin/bash
2 ##############
3 # Name   : find_in_arch
4 # Author : Chris Koeritz
5 # Rights : Copyright (C) 2012-$now by Feisty Meow Concerns, Ltd.
6 ##############
7 # This script is free software; you can modify/redistribute it under the terms
8 # of the GNU General Public License. [ http://www.gnu.org/licenses/gpl.html ]
9 # Feel free to send updates to: [ fred@gruntose.com ]
10 ##############
11 #
12 # scours through the archive files (tar, zip, etc) in a directory looking for a pattern
13 # in the file.  any matches are reported.
14
15 pattern="$1"; shift
16 dir="$1"; shift
17
18 if [ -z "$dir" -o -z "$pattern" ]; then
19   echo This utility requires a pattern string that will be sought within a
20   echo directory, and the directory to scan.  Any matches are reported.
21   exit 1
22 fi
23
24 TMPFILE="$(mktemp "$TMP/jarfinding.XXXXXX")"
25
26 #hmmm: below would be nicer if we had a util that told us all the types of archives
27 #      that we support.  then we could just skim across those types.
28
29 # locate all the archive files under the path.
30 find "$dir" -iname "*.jar" -o -iname "*.zip" -o -iname "*.tar" \
31   -o -iname "*.iar" -o -iname "*.oar" -o -iname "*.bz2" -o -iname "*.snarf" \
32   >"$TMPFILE"
33
34 while read input_text; do
35   bash $FEISTY_MEOW_SCRIPTS/archival/list_arch.sh "$input_text" 2>&1 | grep -i "$pattern" >/dev/null
36   if [ $? -eq 0 ]; then echo ==== Found pattern in $input_text ====; fi
37 done <"$TMPFILE"
38
39 \rm -f "$TMPFILE"
40
41