- #!/bin/bash
- # This script searches the Documents folder in the /home dir of
- # the current user for a given string.
- # Usage: script.sh "query"
- docs="${HOME}/Documents"
- if [[ -z $1 ]]; then
- echo -e "Usage: $(basename "$0") \"query\"\n"
- exit
- elif [[ ! -d $docs ]]; then
- echo -e "\"${docs}\" does not exist!\n"
- exit
- fi
- for i in "$docs"/*; do
- if [[ $(file --brief "$i") =~ "ASCII" ]]; then
- grep -iH --colour "$1" "$i"
- fi
- done
doc search script
Posted by Anonymous on Mon 3rd Sep 2012 05:17
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.