1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
#!/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 $? |