[Top][All Lists]

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

bug#6605: +N lines broken with /usr/bin/tail (GNU coreutils) 7.4

From: Bob Proulx
Subject: bug#6605: +N lines broken with /usr/bin/tail (GNU coreutils) 7.4
Date: Thu, 15 Jul 2010 15:15:08 -0600
User-agent: Mutt/1.5.18 (2008-05-17)

Forest Oakwater wrote:
> Thank you for the information.  Would you consider updating the
> builtin documentation and man page to match the behavior of the
> program?

You say that like it doesn't match now.  :-)  But it does.  You even
quoted the important parts in your original message.

You wrote:
>  -n, --lines=N            output the last N lines, instead of the last 10;
>                           or use +N to output lines starting with the Nth

So I know you have an older version of the program with the older
version of the online docs.  But those are strictly correct!  The
confusion you are experiencing comes from the -n using 'n' and the
--lines=N using 'N'.  Some time in the last while there was another
discussion of this (it will be in the archive but I don't have time to
look) we decided to change this to K to make it more obvious.  The
current online documentation says:

    -n, --lines=K            output the last K lines, instead of the last 10;
                             or use -n +K to output lines starting with the Kth
  If the first character of K (the number of bytes or lines) is a `+',

We thought it was more clear to use 'K' instead to avoid any confusion
of N with -n.  But as you can see with K it still says about the same
thing.  If you want to use a +NUM then you need to say 'tail -n +2' or
some such.  So the older documentation is correct and the newer
documentation is both correct and more helpful.

> Also, do you know of an efficient POSIX way to filter out the first
> N lines of a text file?

I personally like sed for this.

  sed 1,2d FILE


  sed -n '3,$p' FILE

> # inefficient?
> head -N datafile > datafile.head
> diff datafile.head datafile |grep '^>' |cut -c3- > datafile.new
> mv datafile.new datafile

Please, my eyes, the pain! :-}


reply via email to

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