... OP wrote: > 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"
You could write a simple script doing the matching, aka /tmp/match.sh containing these lines: #!/bin/sh cat "$1" | tr '\n' ' ' | grep -qE 'import javax\.swing.*new BufferedReader' && echo "$1" and a suitable find invocation $ find DIRECTORY -name '*.java' -exec /tmp/match.sh "{}" \; Unfortunately, this will invoke the script for all ".java" files below DIRECTORY which is why I would not use it on large amounts of data. To search for special characters, e.g. the sequences of spaces mentioned, you can use extended regular expressions. HTH Linux-Fan. -- http://masysma.ohost.de/
signature.asc
Description: OpenPGP digital signature