Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
An alternative to grep is Awk, which makes this pretty easy. To find lines which contain both: find . -type f -exec awk '/foo/ && /bar/' {} + (Maybe add { print FILENAME ":" FNR ":" $0...
Answer
#1: Initial revision
An alternative to `grep` is Awk, which makes this pretty easy. To find lines which contain both: ``` find . -type f -exec awk '/foo/ && /bar/' {} + ``` (Maybe add `{ print FILENAME ":" FNR ":" $0 }` before the closing quote if you want the filename and the line number.) To find _files_ which contain both; ``` find . -type f -exec awk 'FNR==1 { foo=0; bar=0 } foo && bar { print FILENAME; nextfile } /foo/ { ++foo } /bar/ { ++bar }' {} + ```