What's the Solaris equivalent to the BSD's 'tail -n100'?

前提是你 提交于 2019-12-06 21:08:24

问题


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.


回答1:


Just remove the "n"

tail -100



回答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.




回答3:


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.



来源:https://stackoverflow.com/questions/314321/whats-the-solaris-equivalent-to-the-bsds-tail-n100

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!