Skip to main content
added 205 characters in body
Source Link
John1024
  • 76.4k
  • 12
  • 176
  • 165

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.

The other grep options

-r tells grep to search files and directories recursively.

-I tells grep to ignore binary files

-h tells grep to print the match without the filename attached.

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.

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.

The other grep options

-r tells grep to search files and directories recursively.

-I tells grep to ignore binary files

-h tells grep to print the match without the filename attached.

added 47 characters in body
Source Link
John1024
  • 76.4k
  • 12
  • 176
  • 165

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.

-z is not available on On BSD/OSX versions of grep, the NUL input option is not available and -z means something else.

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.

-z is not available on BSD/OSX versions of grep.

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.

Source Link
John1024
  • 76.4k
  • 12
  • 176
  • 165

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.

-z is not available on BSD/OSX versions of grep.