Is there a way to use grep or awk to find text files that contain both e.g. “a” and “b” but in this case “a” and “b” are on different lines?
Is there a way to use grep or awk to find text files that
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here’s a simple
awksolution:A slightly simpler way is to just use
grep, leveraging its return value as an indicator that the value was found:You may want to redirect standard output, but the above should be simple and functional. You could wrap it in a loop if wanted: