Introduction

A list of solutions for common problems working in a bash shell. Will update as I find them.

Find two words existing on the same line

https://stackoverflow.com/questions/6480687/grep-for-2-words-existing-on-the-same-line

To grep for 2 words existing on the same line, simply do:

grep "word1" FILE | grep "word2"

grep “word1” FILE will print all lines that have word1 in them from FILE, and then grep “word2” will print the lines that have word2 in them. Hence, if you combine these using a pipe, it will show lines containing both word1 and word2.

Useful bash Operations
Tagged on:         

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.