WizardKit/archlive/airootfs/usr/local/bin/msword-search
Alan Mason 546a654c0f 2016-05: Retroactive Updates
* Added build-wk script
  * This will (hopefully) keep the arch-hh folder clean allowing for a better git workflow
* Rebuilt the default settings for wktech for most programs
* Made the theme/icons more consistant between programs
* Changed whiskermenu to more closely match a Windows Start Menu
* Lots of hw-diags updates:
  * Connects to the network automatically
  * Copies all results files to $HOME/Tickets
  * Creates valid tgz archives of the results
  * Uses `mktemp` for setting TMP_DIR
* mount-all-drives now opens the FileManager if lauched w/ Super+M
* Probably more...
2017-12-06 17:47:06 -08:00

38 lines
No EOL
832 B
Bash

#!/bin/bash
TMP_FILE="$(mktemp)"
IFS=$'\n'
for s in $*; do
REGEX="$s"
REGEX=$(echo "$REGEX" | sed -r 's/\s+/\\s\*/g')
# Word Doc
for d in *doc; do
if antiword "$d" | grep -iqsP "($REGEX)"; then
echo "Possible match: $d"
echo "$d" >> "$TMP_FILE"
fi
done
# Word Docx
for d in *docx; do
if unzip -p "$d" word/document.xml | grep -iqsP "($REGEX)"; then
echo "Possible match: $d"
echo "$d" >> "$TMP_FILE"
fi
done
done
# Cleanup results
if [[ -s "$TMP_FILE" ]]; then
sort -u "$TMP_FILE" >> "$HOME/msword-matches.txt"
fi
rm "$TMP_FILE"
# Done
if [[ -s "$HOME/msword-matches.txt" ]]; then
echo "Found $(wc -l "$HOME/msword-matches.txt") possible matches"
echo "The results have been saved to $HOME"
fi