HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/share/doc/zsh-common/examples/Functions/zpgrep
# Usage: zpgrep <perl5-compatible regex> <file1> <file2> ... <fileN>
#

zpgrep() {
local file pattern

pattern=$1
shift

if ((! ARGC)) then
	set -- -
fi

pcre_compile $pattern
pcre_study

for file
do
	if [[ "$file" == - ]] then
		while read -u0 buf; do pcre_match $buf && print $buf; done
	else
		while read -u0 buf; do pcre_match $buf && print $buf; done < "$file"
	fi
done
}