Unix Programming - tail: positive argument

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > April 2006 > tail: positive argument





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author tail: positive argument
dragoncoder

2006-04-27, 7:55 am

Hello experts,

I read somewhere that tail command takes positive arguments also. I
know that tail -10 filename prints last 10 lines of file filename. Is
it possible to give command like tail +10 filename ?

Thanks.

Nils O. Selåsdal

2006-04-27, 7:55 am

dragoncoder wrote:
> Hello experts,
>
> I read somewhere that tail command takes positive arguments also. I
> know that tail -10 filename prints last 10 lines of file filename. Is
> it possible to give command like tail +10 filename ?


The manpage for tail(1) documents this.
dragoncoder

2006-04-27, 7:55 am


Nils O. Sel=E5sdal wrote:
> dragoncoder wrote:
>
> The manpage for tail(1) documents this.


I have already browsed the man pages before posting my question here.
I know man pages give answer to everything but then what is the use of
having a forum like this?
Everyone question in this world can be answered like "Go and read the
book/manual/info" but thats not the answer to my question.

Nils O. Selåsdal

2006-04-27, 7:55 am

dragoncoder wrote:
> Nils O. Selåsdal wrote:
>
> I have already browsed the man pages before posting my question here.
> I know man pages give answer to everything but then what is the use of
> having a forum like this?
> Everyone question in this world can be answered like "Go and read the
> book/manual/info" but thats not the answer to my question.
>

Mine told me
"The display begins at a byte, line or 512-byte block location in the
input. Numbers having a leading plus (``+'') sign are relative to the
beginning of the input, for example, ``-c +2'' starts the display at the
second byte of the input. "
Francis Gudin

2006-04-27, 7:55 am

On 17-04-2006, dragoncoder <pktiwary@gmail.com> wrote:
>
> Nils O. Selåsdal wrote:
>
> I have already browsed the man pages before posting my question here.
> I know man pages give answer to everything but then what is the use of
> having a forum like this?
> Everyone question in this world can be answered like "Go and read the
> book/manual/info" but thats not the answer to my question.
>


Of course, and you didn't understand this (excerpt from tail(1) on
DragonFly):
"Numbers having a leading plus (``+'') sign are relative to the
beginning of the input, for example, ``-c +2'' starts the display
at the second byte of the input."

And this is the _third line_ of the manpage.

Regards
Burton Samograd

2006-04-27, 7:55 am

"dragoncoder" <pktiwary@gmail.com> writes:

> Hello experts,
>
> I read somewhere that tail command takes positive arguments also. I
> know that tail -10 filename prints last 10 lines of file filename. Is
> it possible to give command like tail +10 filename ?


tail +10 README
tail: cannot open `+10' for reading: No such file or directory
==> README <==
<snip README contents>

not with GNU tail it seems...

--
burton samograd kruhft .at. gmail
kruhft.blogspot.com www.myspace.com/kruhft metashell.blogspot.com
Nils O. Selåsdal

2006-04-27, 7:55 am

Burton Samograd wrote:
> "dragoncoder" <pktiwary@gmail.com> writes:
>
>
> tail +10 README
> tail: cannot open `+10' for reading: No such file or directory
> ==> README <==
> <snip README contents>
>
> not with GNU tail it seems...


That's the other point, if the manpage didn't mention
this - assume you cannot.

Daniel Rock

2006-04-27, 7:55 am

Burton Samograd <kruhftREMOVE@gmail.com> wrote:
> tail +10 README
> tail: cannot open `+10' for reading: No such file or directory
> ==> README <==
> <snip README contents>
>
> not with GNU tail it seems...


"tail +-NUMBER" works on most systems just for convenience. The correct
syntax should be:

tail -n +-NUMBER

(-n implicitly assumed).

See a description of the standard:

http://www.opengroup.org/onlinepubs...ities/tail.html

--
Daniel
Bit Twister

2006-04-27, 7:55 am

On 17 Apr 2006 10:55:29 -0700, dragoncoder wrote:

> I have already browsed the man pages before posting my question here.


And we know this how?

> I know man pages give answer to everything but then what is the use of
> having a forum like this?


You may want to read http://www.catb.org/~esr/faqs/smart-questions.html
Martin Blume

2006-04-27, 7:55 am

"Burton Samograd" schrieb
>
> tail +10 README
> tail: cannot open `+10' for reading:
> No such file or directory
> ==> README <==
> <snip README contents>
>
> not with GNU tail it seems...
>

Well, you have to read the manual very attentively
(and try it out ... :-)).

$ cat tailtest
line 1
line 2
line 3
line 4
line 5
line 6
line 7
line 8
line 9
line 10
line 11
line 12
line 13
line 14
line 15
line 16
line 17
line 18
line 19
line 20
$ tail --lines=5 tailtest
line 16
line 17
line 18
line 19
line 20
$ tail --lines=+5 tailtest
line 5
line 6
line 7
line 8
line 9
line 10
line 11
line 12
line 13
line 14
line 15
line 16
line 17
line 18
line 19
line 20

But I agree, the man page might have been written
better.

HTH
Martin


Keith Thompson

2006-04-27, 7:55 am

Burton Samograd <kruhftREMOVE@gmail.com> writes:
> "dragoncoder" <pktiwary@gmail.com> writes:
>
> tail +10 README
> tail: cannot open `+10' for reading: No such file or directory
> ==> README <==
> <snip README contents>
>
> not with GNU tail it seems...


It worked with GNU tail when I tried it. Perhaps it depends on which
version of coreutils (or, before that, textutils) you're using. In
some versions, it may also depend on certain environment variables.

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Keith Thompson

2006-04-27, 7:55 am

"dragoncoder" <pktiwary@gmail.com> writes:
> Nils O. Selåsdal wrote:
>
> I have already browsed the man pages before posting my question here.
> I know man pages give answer to everything but then what is the use of
> having a forum like this?


What is the use of having man pages?

A forum like this is useful for answering questions that aren't
answered in the man pages.

> Everyone question in this world can be answered like "Go and read the
> book/manual/info" but thats not the answer to my question.


As far as I can tell, that is precisely the answer to your question.
"man tail" with a search for the '+' character should take you
directly to the section of the man page tha answers your question. Is
there some reason that didn't work for you?

Another possible solution springs to mind. Your question was
Is it possible to give command like tail +10 filename ?
What happened when you tried it?

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com