On Sep 7, 10:30 am, "Robert Klemme" <shortcut... / googlemail.com>
wrote:
> 2007/9/7, William James <w_a_x_... / yahoo.com>:
>
> > On Sep 7, 4:50 am, "Robert Klemme" <shortcut... / googlemail.com> wrote:
> > > 2007/9/7, Bulhac Mihai <mihai.bul... / yahoo.com>:
>
> > > > how can i read only a line from a txt file?
> > > > for example i want to read only line 3
>
> > > sed -ne '3 p' your_file
>
> > > robert
>
> > awk "3==NR" your_file
>
> When I think about it, this is probably more efficient for large files
> and low line numbers:
>
> head -3 your_file | tail -1

awk "3==NR{print;exit}" your_file

The rule is: never use anything other than awk unless
you have to.