help-bash
[Top][All Lists]
Advanced

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

Printing arbitrary line range from files


From: lisa-asket
Subject: Printing arbitrary line range from files
Date: Mon, 28 Jun 2021 05:44:10 +0200 (CEST)

Does not function very well when I do



print-lines 5 8 .



print-lines ()
  {
    na=$1
    nb=$2
    dir=$3

    find "$dir" \( -name \*.org -o -name \*.texi \)  \
      | xargs sed -n "$na,${nb}p"
  }




From: Greg Wooledge <greg@wooledge.org>
To: help-bash@gnu.org
Subject: Re: Printing arbitrary line range from files
Date: 28/06/2021 05:10:19 Europe/Paris

On Mon, Jun 28, 2021 at 05:03:37AM +0200, lisa-asket@perso.be wrote:
> I want to print lines from files starting from line number "na" to line 
> number "nb".

https://mywiki.wooledge.org/BashFAQ/011

> Have written the following function, which uses head, but now want to extend 
> it to use
> 
> "sed" with "na" and "nb".

sed -n "$na,${nb}p"

(Various alternatives and optimizations are possible. See the FAQ page.)




reply via email to

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