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
I have text (xml actually) files. Some files contain 'foo', some contain 'bar', some contain neither and some contain both. It's the both I'm interested in. How do I do an AND search on words in...
#2: Post edited
grep AND search for multiple words in files
Hi all,- I have text (xml actually) files. Some files contain 'foo', some contain 'bar', some contain neither and some contain both. It's the both I'm interested in.
- How do I do an AND search on words in files in folders (recursively) with grep? I'm using git bash in windows, so either a cygwin or win10 solution works.
- I had thought `pipe`ing to grep would work as it seems to be the solution for multiple text on a line, but I don't think I've changed it to work for files correctly.
This is what I tried:`$ grep -rnw . -e 'foo' | grep -e 'bar'`- Can someone tell me how to fix my grep call?
- I have text (xml actually) files. Some files contain 'foo', some contain 'bar', some contain neither and some contain both. It's the both I'm interested in.
- How do I do an AND search on words in files in folders (recursively) with grep? I'm using git bash in windows, so either a cygwin or win10 solution works.
- I had thought `pipe`ing to grep would work as it seems to be the solution for multiple text on a line, but I don't think I've changed it to work for files correctly.
- This is what I tried:
- ```bash
- $ grep -rnw . -e 'foo' | grep -e 'bar'
- ```
- Can someone tell me how to fix my grep call?
#1: Initial revision
grep AND search for multiple words in files
Hi all, I have text (xml actually) files. Some files contain 'foo', some contain 'bar', some contain neither and some contain both. It's the both I'm interested in. How do I do an AND search on words in files in folders (recursively) with grep? I'm using git bash in windows, so either a cygwin or win10 solution works. I had thought `pipe`ing to grep would work as it seems to be the solution for multiple text on a line, but I don't think I've changed it to work for files correctly. This is what I tried: `$ grep -rnw . -e 'foo' | grep -e 'bar'` Can someone tell me how to fix my grep call?