File: max-count-vs-context

package info (click to toggle)
grep 2.6.3-3%2Bsqueeze1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 8,368 kB
  • ctags: 4,688
  • sloc: ansic: 15,006; sh: 8,554; makefile: 210; awk: 71; sed: 16
file content (24 lines) | stat: -rwxr-xr-x 486 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh
# Show how -m1 works with -A N when a 2nd match is < N lines after the first
: ${srcdir=.}
. "$srcdir/init.sh"; path_prepend_ ../src

cat <<EOF > in || framework_failure_
needle
1st line of context
2nd line of context
3rd line of context
another needle
5th line of context relative to first match
6th line...
EOF

sed 4q in > exp || framework_failure_

fail=0
grep -m1 -A5 needle in > out 2>err || fail=1

compare out exp || fail=1
compare err /dev/null || fail=1

Exit $fail