Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- SEARCHPATH='/var/data'
- KEYWORDS="-e langenscheidt"
- TMPPATH='/var/data/tmp'
- ARCHIVES=('zip' 'tar' 'gz' 'bz2' 'xz')
- MATCHES_NOW=$(find . | grep $KEYWORDS)
- MATCHES="$MATCHES\n$MATCHES_NOW"
- echo $MATCHES_NOW >> partial-results.txt
- ARCHIVE_NO=0
- for EXT in $ARCHIVES; do
- echo "Checking for archives (*.$EXT)"
- XZ=$(find "$SEARCHPATH" -iname "*.$EXT")
- for ARCHIVE in $ZIP; do
- echo "Checking $ARCHIVE"
- mkdir -pv "$TMPPATH"
- cd "$TMPPATH"
- case $EXT in
- zip)
- unzip $ARCHIVE
- ;;
- tar)
- tar -xf $ARCHIVE
- ;;
- gz|bz2)
- tar -xf $ARCHIVE
- ;;
- xz)
- cat $ARCHIVE | unxz -1 - | tar -x
- ;;
- esac
- MATCHES_NOW=$(find . | grep $KEYWORDS)
- MATCHES="$MATCHES\n$MATCHES_NOW"
- echo $MATCHES_NOW >> partial-results.txt
- if [ ! -z "$MATCHES_NOW" ]; then
- echo $MATCHES_NOW > "archive-$ARCHIVE_NO.txt"
- fi
- echo "$ARCHIVE_NO:$ARCHIVE" > "archives.txt"
- rm -rf "$TMPPATH"
- ARCHIVE_NO=$(($ARCHIVE_NO+1))
- done
- done
- echo $MATCHES > results.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement