pastebin - collaborative debugging tool
kpaste.net RSS


doc search script
Posted by Anonymous on Mon 3rd Sep 2012 05:17
raw | new post

  1. #!/bin/bash
  2. # This script searches the Documents folder in the /home dir of
  3. # the current user for a given string.
  4. # Usage: script.sh "query"
  5.  
  6. docs="${HOME}/Documents"
  7.  
  8. if [[ -z $1 ]]; then
  9.         echo -e "Usage: $(basename "$0") \"query\"\n"
  10.         exit
  11. elif [[ ! -d $docs ]]; then
  12.         echo -e "\"${docs}\" does not exist!\n"
  13.         exit
  14. fi
  15.  
  16. for i in "$docs"/*; do
  17.         if [[ $(file --brief "$i") =~ "ASCII" ]]; then
  18.                 grep -iH --colour "$1" "$i"
  19.         fi
  20. done

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.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at