10

I've looked this up a thousand times, and I always forget it, so, here for eternity:

Solaris has a bit of an awkward syntax for tail.

How do I do the equivalent of BSD's tail -nN?

What I want are the last N lines from tail's input.

kch
  • 77,385
  • 46
  • 136
  • 148

3 Answers3

17

Just remove the "n"

tail -100
Ulf Lindback
  • 13,974
  • 3
  • 40
  • 31
  • nice. I always remember that I need to specify -l somehow. Which would be -100l. Now I know I don't even need the l. – kch Nov 24 '08 at 14:50
2

Or you can use:

/usr/xpg4/bin/tail

which does behave like you want (tail -nN).

xpg4 = Xopen Portability Guide Issue 4, contains binaries strictly compliant with several POSIX and other standards. The differences with the former ones are usually details in options supported and behavior.

According to your distribution, there is also /usr/xpg6/bin, /usr/openwin/bin (OpenWindows commands), /usr/dt/bin (CDE desktop commands), /usr/sfw/bin (Solaris freeware) and various other.

For instance, Solaris Express is introducing /usr/gnu/bin to provide Gnu binaries with their custom extensions and specificities.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

Cross-platform variant of tail -n 10 for scripts:

sed -e :a -e '$q;N;11,$D;ba' file

This works the same for Linux and Solaris.

Community
  • 1
  • 1
Sasha Golikov
  • 638
  • 5
  • 11