bug-textutils
[Top][All Lists]
Advanced

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

Re: important feature for head/tail


From: Bob Proulx
Subject: Re: important feature for head/tail
Date: Thu, 28 Mar 2002 23:16:35 -0700

> A) behind the scenes, if these programs arent already almost the same
> source, they should be

It would seem that if you can't tell from the behavior of the program
than as a user of the program it does not matter.

> B) MORE IMPORTANTLY: i think its very useful to have the following
> features in either head or tail:
> 
> instead of just tail -n10, which takes the last 10 lines, there should
> be a way of doing all lines from line 10 to the end.

There is.  This is documented in both the --help output and the info
documentation.

  tail -n +10

  If the first character of N (the number of bytes or lines) is a `+',
  print beginning with the Nth item from the start of each file, otherwise,
  print the last N items in the file.  N may have a multiplier suffix:
  b for 512, k for 1024, m for 1048576 (1 Meg).  A first OPTION of -VALUE
  or +VALUE is treated like -n VALUE or -n +VALUE unless VALUE has one of
  the [bkm] suffix multipliers, in which case it is treated like -c VALUE
  or -c +VALUE.

> C) i think this really calls for a new application to be created from
> these 2. Some of its features wrt to cropping the file:

If N=3 and M=7 then the following are examples.  And some alternatives
as well to show that there are many different ways of doing this.

> first N lines

  head -n 3 file
  sed 3q file

> last N lines

  tail -n 3 file

> last lines from line N

  tail -n +3 file
  sed -n '3,$p' file

> lines from line N to line M

  sed -n '3,7p' file
  perl -ne 'print if 3 ... 7' file
  awk '3 <= NR && NR <= 7' file

> and then give it the best other features from head and tail. 
> 
> EXAMPLE: since its all in 1 file, and now all the features support
> "follow" you can:
> 
> take lines 20-30 from a file and then -follow it into another file
> take all lines after line 5 and then -follow it into that file
> 
> very very useful....

I am sorry but I don't follow this myself.

Bob



reply via email to

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