[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

find'ing files containing certain words (all of them) ...



 the short bash script bellow you can use to find text files
containing one word, but my attempts at trying to make it find more
than one word within the same file haven't been successful

 Of course, you can go monkey and list all files containing each word
and then sort and compare those list, but I want to do just one search
per file

 You can find all files containing either "import" or
"BufferedReader", but not both words in the same file. Also, how can
you use such a the same of a similar script to search for sequences of
characters containing spaces and other especial characters? Say,
something like:

_WRD="import javax.swing|new BufferedReader"

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
# 2 edit
_WRD="import|BufferedReader"

# !2 edit

_PP="|"

_RPLC="_"

_DT=$(date +%Y%m%d%H%M%S)
_OFL="${_DT}_${_WRD//${_PP}/${_RPLC}}".search.log

echo "\$_OFL: |$_OFL|"

date; time find /media/sdb1/prjx -type f -iname "*.java" -exec grep -l
"${_WRD}" '{}' \; > ${_OFL}; date

wc -l ${_OFL}

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

 lbrtchx


Reply to: