#!/bin/sh ## ## Nautilus ## SCRIPT: 00_findSTRorSTR_in_dirTEXTFILS_recursive.sh ## ## PURPOSE: Finds all files, at all levels under the current directory, ## that contain a user-specified string(s) --- the strings are separated ## by a vertical bar (|). ## This script uses the 'find' command and ## a separate utility script that uses 'egrep' and skips files that ## are not text-type files, that is skipping binary files (executables, ## image files, audio files, video files, etc.). ## Ref: page 132 of QUE Unix Shell Commands Quick Reference. ## ## HOW TO USE: In Nautilus, ## click on ANY file (or directory) in a 'navigated to' directory. ## Right-click on the filename and choose this Nautilus script ## (name above). ## ## Created: 2011may23 Based on00_findSTR_in_dirTEXTFILS_recursive.sh ## Changed: ## $1 should be 'quiet' or 'noquiet'. QUIET="$1" ## FOR TESTING: (turn ON display of executed-statements) # set -x ###################################################################### ## Prep a temporary filename, to hold the list of filenames. ## If the user does not have write-permission to the current directory, ## put the list in the /tmp directory. ## Changed this. If the output file goes in the current directory, ## the output file is found as one of the files containing the string. ## So this always put the output file in the /tmp directory. ###################################################################### CURDIR="`pwd`" ## OUTFILE="${USER}_temp_fileLINEScontainingStringS_find-egrep.lis" ## if test ! -w "$CURDIR" ## then ## OUTFILE="/tmp/$OUTFILE" ## fi OUTFILE="/tmp/${USER}_temp_fileLINEScontainingStringS_find-egrep.lis" if test -f "$OUTFILE" then rm -f "$OUTFILE" fi ###################################################################### ## Exit if the current directory is the root (/) or /usr directory. ###################################################################### if test \( "$CURDIR" = "/" -o "$CURDIR" = "/usr" \) then zenity --question --title "Exiting!" \ --text "\ Very many directory levels under $CURDIR. This search Search could take many minutes. Cancel or OK (Go)?" if test $? = 0 then ANS="Yes" else ANS="No" fi if test "$ANS"= "No" then exit fi fi ############################################## ## Prompt for the search stringS, using zenity. ############################################## STRINGS="" STRINGS=$(zenity --entry --title "STRINGS for search of the text files." \ --text "\ Enter STRINGS for the (Case-INsensitive) search of TEXT-FILES, separated by a vertical bar ( | ). Examples: awk|sed|grep|sort |
| | |