Files
percona-toolkit/util/extract-text
2011-08-03 17:17:46 -06:00

20 lines
313 B
Bash
Executable File

#!/usr/bin/env bash
die() {
echo "$1" >&2
exit 1
}
file=$1
from=$2
to=$3
start_line=$(grep --line-number "$from" $file | cut -d':' -f1)
if [ -z "$start_line" ]; then
die "Cannot find $from in $file"
fi
tail -n +$start_line $file | awk "BEGIN { getline; print \$0 } /$to/ { exit } { print }"
exit $?