I can't figure this out. I need to look at every line in file and check out whether it is matching word which is given in variableI started through command read, but I don't know what am I supposed to use after that, I tried grep but I probably used it wrongly.while read line; do if [ $condition  ] ;then echo ok fidone<file.txt
Read lines and match against pattern
bash;read
Here's a quickie for you, simply what we're doing isLine 1: While reading file into variable lineLine 2: Match a regex, echo the $line if matching the word bird echo that line. Do whatever actions you need here, in this if statement.Line 3: End of while loop, which pipes in the file foo.text#!/bin/bashwhile read line; do  if [[ $line =~ bird ]] ; then echo $line; fidone <foo.textNote that bird is a regex. So that you could replace it with for example: bird.*word to match the same line with a regular expression.Try it with a file like so, called foo.text with the contents:my dog is brownher cat is whitethe bird is the word