Muito pertinente esta dúvida.

Vamos olhar no sed1liners, principalmente o ultimo método:

 # print line number 52
 sed -n '52p'                 # method 1
 sed '52!d'                   # method 2
 sed '52q;d'                  # method 3, efficient on large files

Vejamos o motivo pelo qual o comando q pode agilizar o processo:

"On line selection or deletion in which you only need to output lines
from the first part of the file, a "quit" command (q) in the script
will drastically reduce processing time for large files. Thus:

   sed -n '45,50p' filename           # print line nos. 45-50 of a file
   sed -n '51q;45,50p' filename       # same, but executes much faster

A versão em AWK ficaria:

awk 'NR==52{ print ; exit }' filename

On 8/25/07, Leonardo Fedalto <[EMAIL PROTECTED]> wrote:
>
> sed -n 1234p arquivo
>
>  On 8/25/07, William José Vicente <[EMAIL PROTECTED]> wrote:
>  >
>  >   Pessoal,
>  >
>  > alguém sabe uma forma mais eficiente de recuperar uma determinada linha
>  > de um arquivo?
-- 
Tiago B Peczenyj
Linux User #405772

http://peczenyj.blogspot.com/

Responder a