I know that
grep -rhI "# Active" > out.txt
will output any line containing # Active
within the searched directory but I want the entire .txt file contents, so example
example.txt
Line1
Line2
Line3 # Active
Line4
Line5
etc
So if I grep for # Active
I want it to not just output the line containing # Active
within these .txt file but all the other lines too, example
output.txt
Line1
Line2
Line3 # Active
Line4
Line5
etc
Best Answer
For non-GNU versions of
grep
, which are unlikely to have-z
, or if portability is required...-q
suppresses any output but, per usual, exit status is set based on whether or not a pattern match was found. With a pattern matchgrep
returns the success code0
which is equivalent to true and that allows thecat
command to be executed.