#!/bin/bash
# Output $1 to $2 most frequent words (with counts) in merge of given files 
#  so "freqseg 3 7 ... "  gives 3, 4, 5, 6, 7th most freq words.

first=$1; last=$2; shift; shift  ## copy first two arguments and shift away

freq "$@" |
head -$last |                   ## initial 7 lines
tail -$(( last - first + 1 ))   ## final 5 = 7 - 3 + 1 of the first 7 lines

## Alternate: In sh "expr" does algebra:  tail -`expr $last - $first + 1`
## Alternate: "sed" could be used instead of "head" and "tail", as follows:
# freq "$@" | sed -n $first,$last' p'
