using grep to search for multiple arguments

using grep to search for multiple arguments

by Cole Blair -
Number of replies: 1

I've been stuck on parts 4 and 5 of Assignment 1, and I had a question regarding the grep command. I thought I could use a pipeline to send the output of one grep command to another, and then use wc to get the desired value. However, I've noticed that, when using several grep commands in a pipeline, the wc would only be applied to the most recent grep in the pipeline. For example, if I grep for Acinetobacter and then grep for WP_005 (followed by wc -l), the wc I get is the number of total entries with WP_005. If I reverse the order of the grep commands in the pipeline, the wc is just the number of entries with Acinetobacter. In neither circumstance does this actually give me the number of entries with Acinetobacter AND WP_005. Is there a way to use grep to search for multiple arguments in the same pipeline? 

In reply to Cole Blair

Re: using grep to search for multiple arguments

by Cole Blair -
nevermind, I found where I was wrong. I realized that extra greps after the initial grep command do not need the file name with the command, which was applying the other grep arguments to everything in the file, instead of just what was passed through the pipeline