我想打印一个文件的最后n-2行,其中n是文件中的行数。这可以通过执行n= wc -l -2,然后执行tail -n $file来完成。
但是有没有更好的方法呢?我在bash中经常需要这个函数...
发布于 2013-02-08 20:23:35
您可以使用tail -n +3 file跳过前两行(并输出其余n-2行)。
发布于 2013-02-08 20:24:21
如果我没理解错的话,tail -n +3 file应该做你想做的事情。
来自man tail
-n, --lines=K
output the last K lines, instead of the last 10; or use -n +K to output lines starting with the Kthhttps://stackoverflow.com/questions/14772436
复制相似问题