tail command question

I tried to apply the suggestion found HERE on the “tail” command for stripping the header. But when I try it:

tail +2 filename

I get

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:

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!

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

Thank You,

I quote from [shell-fu:browse]$](http://www.shell-fu.org/lister.php?browse&pageno=2:)

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?

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

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

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 10001000, M 10241024, GB 100010001000, G
102410241024, 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:


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


Cheers / Saludos,

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

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

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

On 11/26/2013 12:36 PM, riderplus pecked at the keyboard and wrote:
> jdmcdaniel3;2602251 Wrote:
>> 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!
>
>
Then you want to use -q as well.

Ken