Normally, grep will just show the matching line: $ grep -rhI "# Active" Line3 # Active To see the whole file, add the `-z` flag: $ grep -rhIz "# Active" Line1 Line2 Line3 # Active Line4 Line5 etc `-z` is a GNU extension that tells grep not to use newline as the 'line' separator but to use a NUL character instead. Since text files generally do not have NUL characters in them, this has the effect of telling grep to read the whole file as if it were a single 'line'. Consequently, if there is a match, the whole file is printed. On BSD/OSX versions of grep, the NUL input option is not available and `-z` means something else.