bug-coreutils
[Top][All Lists]
Advanced

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

Re: Not a bug, a wish


From: Didi
Subject: Re: Not a bug, a wish
Date: Thu, 27 Mar 2008 12:11:51 +0100

Hey

So just to clarify would a invert option do the job. So basically if
you specify head -i or  --invert you would print everything except the
head.

so if you want to strip out the first line of a file you could do:
head -n1 -i

Same of course for tail. A little bit like grep -v. What to the
maintainers say? (Jim???) Would something like this be committed? This
is in my eyes a more "do one thing wright" approach than one big
program to stip out head and tail.

Of course the question is how often this would be used and if the
bug/maintenance effort is worth it especially if it can be done easily
in perl, sed, etc...

Cheers Didi

----
www.cern.ch/ribalba / www.ribalba.de
Email / Jabber: address@hidden
Phone (Work) : +41 22 7679376
Skype : ribalba
Address : CERN / IT-FIO-FS / GENEVE 23/ SCHWEIZ
On Thu, Mar 27, 2008 at 1:26 AM, Martin Bernreuther <address@hidden> wrote:
> Hello,
>
>  Am Mittwoch, 26. März 2008 schrieb Micah Cowan:
>
> > > I thank you very much for devolopping coreutils that allows quick and
>  > > simple replacement of SQL queries and check. What I would appreciate is
>  > > a tool that does head and tail in one command, giving the top and bottom
>  > > lines from a piped output.
>
>  I also think that such a command would be easier to use than head and tail,
>  which both just extract lines from a stream and therefore do a similar thing.
>
>
>  > Do you literally mean just the one top line and one bottom line? That
>  > could easily be achieved with the sed command: sed -n '1p;$p'.
>
>  Nice.
>
>  In my case I often want to extract some part of a file (or stream).
>  Consider something like
>         headtail 3:5 inputfile
>  and
>         head -n 5 inputfile | tail -n $[5-3+1]
>  The first version would be "easier to understand" and might
>  be more efficient to implement.
>  (I found the pipe mechanism for file sizes >100 GB not very reliable.)
>  Often you like to remove a header...
>  A negative number is sometimes used in scripting-languages
>  to mark or count from the end of the file like
>         headtail 2:-1 inputfile
>  To just remove the first line a combination of tail and wc
>  theoretically would work (quite inefficient)
>         tail -n $[`wc -l <inputfile`-1] inputfile
>  You might also want to remove a footer like
>         headtail 2:-2 inputfile
>  Using head and tail: How does that work (with n header lines and m footer 
> lines)?
>
>  Is there another easy way to do it? Is "sed" the command the way to go?
>
>
>  > If you need more lines, sed can still do it, but requires a bit more
>  > work. You might look to a simple solution in
>  > awk/Perl/your-scripting-language-of-choice.
>
>  No!!! I definitely don't want to use Perl or 
> "my-scripting-language-of-choice"
>  for such an easy task. What is the sense of these tools then?
>  You probably master most of the coreutil-tasks also with these
>  scripting-languages-of-choice, don't you?
>
>  Martin Bernreuther
>  --
>  _________________________________________
>  Martin Bernreuther      address@hidden
>
>
>
>
>  _______________________________________________
>  Bug-coreutils mailing list
>  address@hidden
>  http://lists.gnu.org/mailman/listinfo/bug-coreutils
>




reply via email to

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