Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: tail command question

  1. #1
    Join Date
    Feb 2011
    Location
    127.0.0.1
    Posts
    472

    Default tail command question

    I tried to apply the suggestion found HERE on the "tail" command for stripping the header. But when I try it:
    Code:
    tail +2 filename
    I get
    Code:
    tail: cannot open ‘+2’ for reading: No such file or directory
    Any ideas whatsoever?
    Reliable + rider = RiDeR PlUs
    ...if you find this helpful, click on the star below...
    +-+ +-+
    |r| |+|
    +-+ +-+

  2. #2
    Join Date
    Mar 2010
    Location
    Austin - Texas
    Posts
    10,140
    Blog Entries
    48

    Smile Re: tail command question

    Quote Originally Posted by riderplus View Post
    I tried to apply the suggestion found HERE on the "tail" command for stripping the header. But when I try it:
    Code:
    tail +2 filename
    I get
    Code:
    tail: cannot open ‘+2’ for reading: No such file or directory
    Any ideas whatsoever?
    If you wanted the last two lines, which is hard to tell based on your request:

    Code:
    tail --lines=2 filename
    You can use "man tail" for more information.

    Thank You,
    My Blog: https://forums.opensuse.org/blogs/jdmcdaniel3/

    Software efficiency halves every 18 months, thus compensating for Moore's Law

    Its James again from Austin, Texas

  3. #3
    Join Date
    Feb 2011
    Location
    127.0.0.1
    Posts
    472

    Default Re: tail command question

    Quote Originally Posted by jdmcdaniel3 View Post
    If you wanted the last two lines, which is hard to tell based on your request:

    Code:
    tail --lines=2 filename
    You can use "man tail" for more information.

    Thank You,
    I wanted to strip the header, you can check on that webpage to see the tip!
    Reliable + rider = RiDeR PlUs
    ...if you find this helpful, click on the star below...
    +-+ +-+
    |r| |+|
    +-+ +-+

  4. #4
    Join Date
    Mar 2010
    Location
    Austin - Texas
    Posts
    10,140
    Blog Entries
    48

    Smile Re: tail command question

    Quote Originally Posted by riderplus View Post
    I wanted to strip the header, you can check on that webpage to see the tip!
    Tail starts from the bottom, not the top and does not care about the top.

    Thank You,
    My Blog: https://forums.opensuse.org/blogs/jdmcdaniel3/

    Software efficiency halves every 18 months, thus compensating for Moore's Law

    Its James again from Austin, Texas

  5. #5
    Join Date
    Feb 2011
    Location
    127.0.0.1
    Posts
    472

    Default Re: tail command question

    Quote Originally Posted by jdmcdaniel3 View Post
    Tail starts from the bottom, not the top and does not care about the top.

    Thank You,
    I quote from [shell-fu:browse]$
    Code:
    Strip the header line from a file: 
    tail +2 file
    It's tip number #90 and it has 7 Likes...how's that even possible?
    Reliable + rider = RiDeR PlUs
    ...if you find this helpful, click on the star below...
    +-+ +-+
    |r| |+|
    +-+ +-+

  6. #6
    Join Date
    Jul 2008
    Location
    Seattle, WA
    Posts
    17,071

    Default Re: tail command question

    On Tue, 26 Nov 2013 18:36:01 +0000, riderplus wrote:

    > It's tip number #90 and it has 7 Likes...how's that even possible?


    While it doesn't say so in the man page or --help output for tail, it
    does seem to work here just fine.

    Except that "+2" means "start at the second line," not "skip the first
    two lines".

    I'm using tcsh as my shell on openSUSE 12.2.

    Jim

    --
    Jim Henderson
    openSUSE Forums Administrator
    Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

  7. #7
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

    Default Re: tail command question

    On 2013-11-26 18:36, jdmcdaniel3 wrote:
    >
    > riderplus;2602263 Wrote:
    >> I wanted to strip the header, you can check on that webpage to see the
    >> tip!

    >
    > Tail starts from the bottom, not the top and does not care about the
    > top.


    Read, from the man page:


    ······················
    If the first character of K (the number of bytes or lines) is a
    '+', print beginning with the Kth item from the start of each file,
    otherwise, print the last K
    items in the file. K may have a multiplier suffix: b 512, kB
    1000, K 1024, MB 1000*1000, M 1024*1024, GB 1000*1000*1000, G
    1024*1024*1024, and so on for T, P,
    E, Z, Y.
    ······················++-


    The idea is to strip, ie, delete, the first two lines and output from
    there to the end. However, there is something wrong because 'head' tries
    to interpret it as a filename. It might be a bug.

    This syntax, however, works:

    Code:
    tail --lines=+2 /var/log/messages

    --
    Cheers / Saludos,

    Carlos E. R.
    (from 12.3 x86_64 "Dartmouth" at Telcontar)

  8. #8
    Join Date
    Feb 2011
    Location
    127.0.0.1
    Posts
    472

    Default Re: tail command question

    Quote Originally Posted by hendersj View Post
    On Tue, 26 Nov 2013 18:36:01 +0000, riderplus wrote:

    > It's tip number #90 and it has 7 Likes...how's that even possible?


    While it doesn't say so in the man page or --help output for tail, it
    does seem to work here just fine.

    Except that "+2" means "start at the second line," not "skip the first
    two lines".

    I'm using tcsh as my shell on openSUSE 12.2.

    Jim

    --
    Jim Henderson
    openSUSE Forums Administrator
    Forum Use Terms & Conditions at openSUSE Forums FAQ
    Jim, it doesn't work on bash, openSUSE 12.3
    Thanks for replying.
    Reliable + rider = RiDeR PlUs
    ...if you find this helpful, click on the star below...
    +-+ +-+
    |r| |+|
    +-+ +-+

  9. #9
    Join Date
    Jul 2008
    Location
    Seattle, WA
    Posts
    17,071

    Default Re: tail command question

    On Tue, 26 Nov 2013 18:56:02 +0000, riderplus wrote:

    > Jim, it doesn't work on bash, openSUSE 12.3 Thanks for replying.


    It's possible a change was introduced in the build of tail. Try the
    alternate suggestion Carlos just posted (I think James also mentioned it).

    Jim
    --
    Jim Henderson
    openSUSE Forums Administrator
    Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

  10. #10

    Default Re: tail command question

    On 11/26/2013 12:16 PM, jdmcdaniel3 pecked at the keyboard and wrote:
    > riderplus;2602246 Wrote:
    >> I tried to apply the suggestion found 'HERE'
    >> (http://www.shell-fu.org/lister.php?browse&pageno=2) on the "tail"
    >> command for stripping the header. But when I try it: >

    > Code:
    > --------------------
    > > > tail +2 filename

    > --------------------
    >>> I get >

    > Code:
    > --------------------
    > > > tail: cannot open ‘+2’ for reading: No such file or directory

    > --------------------
    >>> Any ideas whatsoever?

    > If you wanted the last two lines, which is hard to tell based on your
    > request:
    >
    >
    > Code:
    > --------------------
    > tail --lines=2 filename
    > --------------------
    >
    >
    > You can use "*man tail"* for more information.
    >
    > Thank You,
    >
    >


    Or simply use

    code:

    tail -2 (or whatever number of lines you want to see)

    Ken


Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •