我想打开一个大的错误日志文件(具有数百万行)。要调查,我只需要查看最近的日志即可。因此,我想将大文件的"尾巴"结果复制到新文件。如何获得它?
echo "tail largefile.log" > lastline.txt
这样的东西。但是我需要
的输出tail largefile.log
在lastline.txt中我想也可以使用" sed"命令来实现这一点。
尝试以下:
tail -n 1 largefile.log > lastline.txt
使用-n
参数指定您想要多少行。
the Tail Man页面:
-n, --lines=[+]NUM output the last NUM lines, instead of the last 10; or use -n +NUM to output starting with line NUM