Windows Powershell 中的 Unix tail 等效命令 [英] Unix tail equivalent command in Windows Powershell

查看:76
本文介绍了Windows Powershell 中的 Unix tail 等效命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须查看大文件的最后几行(典型大小为 500MB-2GB).我正在为 Windows Powershell 寻找等效的 Unix 命令 tail.一些可用的替代方法是,

I have to look at the last few lines of a large file (typical size is 500MB-2GB). I am looking for a equivalent of Unix command tail for Windows Powershell. A few alternatives available on are,

http://tailforwin32.sourceforge.net/

Get-Content [filename] | Select-Object -Last 10

对我来说,第一种选择是不允许的,第二种选择很慢.有谁知道 PowerShell 的 tail 的有效实现.

For me, it is not allowed to use the first alternative, and the second alternative is slow. Does anyone know of an efficient implementation of tail for PowerShell.

推荐答案

-wait 参数与 Get-Content 一起使用,这会显示添加到文件中的行.此功能出现在 PowerShell v1 中,但由于某些原因在 v2 中没有很好地记录.

Use the -wait parameter with Get-Content, which displays lines as they are added to the file. This feature was present in PowerShell v1, but for some reason not documented well in v2.

这是一个例子

Get-Content -Path "C:\scripts\test.txt" -Wait

运行后,更新并保存文件,您将在控制台上看到更改.

Once you run this, update and save the file and you will see the changes on the console.

这篇关于Windows Powershell 中的 Unix tail 等效命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆