[pcre-dev] show file name in a spearate line?

Kezdőlap
Üzenet törlése
Szerző: Peng Yu
Dátum:  
Címzett: pcre-dev
Tárgy: [pcre-dev] show file name in a spearate line?
The filenames are shown in the first line of the match, which makes it
not very readable. Is there a way to show the filename in a separate
line?

For example, something like

==> /var/folders/r7/bvmh1vvx41d63snvgbdz7bl40000gr/T/tmp.ogsWFOOz9i <==.

$ cat ./main1.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:

tmpfile=$(mktemp -u)
cat > "$tmpfile" <<EOF
abc
===
xyz
123
EOF

set -v
pcregrep --color -M 'b[^\n]*(\n[^\n]*){0,3}y' "$tmpfile" "$tmpfile"
$ ./main1.sh
pcregrep --color -M 'b[^\n]*(\n[^\n]*){0,3}y' "$tmpfile" "$tmpfile"
/var/folders/r7/bvmh1vvx41d63snvgbdz7bl40000gr/T/tmp.ogsWFOOz9i:abc
===
xyz
/var/folders/r7/bvmh1vvx41d63snvgbdz7bl40000gr/T/tmp.ogsWFOOz9i:abc
===
xyz

--
Regards,
Peng