help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Adding option to select file types


From: lisa-asket
Subject: Adding option to select file types
Date: Mon, 5 Jul 2021 06:48:14 +0200 (CEST)

I have the following bash function and I want an option that allows me

to pass the file type if I do not want the default .org and .texi



-----



print-region ()
  {
    na=$1
    nb=$2
    dir=$3
    
      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}' {} +
  }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]