linux - 检索最后 100 行日志

我需要从日志文件中检索最后 100 行日志。 我尝试了 sed 命令

sed -n -e '100,$p' logfilename

请告诉我如何更改此命令以专门检索 last 100 行。

最佳答案

您可以使用 tail命令如下:

tail -100 <log file>   > newLogfile

现在最后 100 行将出现在 newLogfile

编辑:

twalberg 提到的最新版本的 tail使用命令:

tail -n 100 <log file>   > newLogfile

https://stackoverflow.com/questions/36989457/

相关文章:

linux - 如何删除具有特定名称的文件夹

python - 如何在使用 Python 插入 MySQL 数据库后获取 "id"?

python - Windows Scipy 安装 : No Lapack/Blas Resourc

linux - Mac 和 Linux 上的文本文件中的递归搜索和替换

python - 将元组转换为列表并返回

linux - 如何在 Bash 中运行超时的进程?

linux - 没有行号的 Bash 历史记录

python - pandas 获取不在其他数据框中的行

linux - 在 Linux 脚本中隐藏终端上的用户输入

python - 为什么在 Python 3 中 x**4.0 比 x**4 快?