What is this expression supposed to be doing?
grep -i Keyword1 | grep -i Keyword2 file.txt
Is it supposed to return the lines which contain either keyword 1 or keyword 2? I ask this because that is not what i am getting.I am somehow always getting the lines with keyword 2 and also the thing doesnt seem to complete.I mean when you run a normal command it returns to the command prompt after finishing.Doesnt seem to be happening when I run the above.Is there some kind of piping happening here?
This doesn’t really make sense.
|is a pipe, it redirects stdin/stdout:a | bredirectsas stdout tobs stdin.grep, without a file as parameter, will take input from stdin, which is why your command doesn’t return.What you want is
Which will grep for
Keyword1, and the output will be grepped forKeyword2. This will result in a logicaland, filters forKeyword1 AND Keyword2.