I have the following bash function to print between two line numbers, for files watching file types .texi and .org recursively in a particular directory.
I would like to be able to supply the file extensions to search for using the -e option using , as delimiter.  Example:  -e el,texi,org
print-region ()
{
  # Process command line options
  shortopts="hvd:e:p:q:"
  longopts="help,version,directory:,extension:,startline:,stoplinene:,"
  opts=$(getopt -o "$shortopts" -l "$longopts" -n "$(basename $0)" -- "$@")
  if [ $? -eq 0 ]; then
    eval "set -- ${opts}"
    while [ $# -gt 0 ]; do
      case "$1" in
        --)
          shift;  break  ;;
        -h|-\?|--help)
          help=1
      local -r f=0
      break
      ;;
        -v|--version)
      version=1;  shift;  break  ;;
        -d|--directory)
      local -r dir=$2
      shift 2
      ;;
        -e|--extension)
      fltype=$2
      shift 2
      ;;
        -p|--startline)
      local -r na=$2;  shift 2  ;;
        -q|--stopline)
      local -r nb=$2;  shift 2  ;;
      esac
    done
  else
    shorthelp=1 # getopt returned (and reported) an error.
  fi
  if [[ $na =~ ^[[:digit:]]+$ ]] && [[ $nb =~ ^[[:digit:]]+$ ]]  \
  && [[ -d $dir ]]; then
    
    find "$dir" \( -name \*.org -o -name \*.texi \)  \
      -exec awk -v a="$na" -v b="$nb"                \
            'FNR == 1 {s="\n==> "FILENAME" <==\n"; f = 0}
             FNR == a {print s; f = 1}
             f {print; if (FNR == b) nextfile}' {} +
  fi
}
    
-eoption? By the way, to print text between two line numbers,sed -n ${NUM1},${NUM2}pis a simpler solution than your awk program.sed,but that would require calling sed for each file, whereasawkcan take any number of files.-e|--extensionin thegetoptsection. I would pass something like-e texi,org,elusing comma as delimiter for different file types.-name "*$ext" -oand collect the whole thing to an array.