.NET Framework - Any command like the tail -f from unix/linux to open log-files

Asked By Florian Broeder on 21-Jun-07 10:10 AM
Hey Guys,

is there any command in Windows Powershell like the "tail -f <filename>"
command from unix/linux to open a log-file once an see the changes directly?
thanks for answers!
regards
florian




Hal Rottenberg replied on 21-Jun-07 11:34 AM
Goooood question, I am also awaiting the answer from the experts.
gil.qi.zhan replied on 21-Jun-07 11:41 AM
Hi, Florian:

Run "get-help get-eventlog -examples" in powershell. It shows 3
examples of get-eventlog. I suppose 2nd one maybe is what you want.
It's:

get-eventlog -newest 5 -logname application

This command displays the 5 most recent entries in the Application
event log.

BR.
Gil
Shafik replied on 21-Jun-07 12:52 PM
try that:
Get-Content my.txt -Wait
Florian Broeder replied on 22-Jun-07 01:57 AM
thanks, that´s it ;-)

florian
Hal Rottenberg replied on 22-Jun-07 07:06 AM
And it is oddly undocumented.  Where'd you find this?
Neil Chambers replied on 22-Jun-07 08:18 AM
On 2007-06-22 12:06:56 +0100, Hal  Rottenberg <halr9000@gmail.com> said:


I can't speak as to where Shafik picked it up, but I can tell you that
using MOW's fabulous TabCompletion (powertab:
http://thepowershellguy.com/blogs/posh/pages/powertab.aspx) will give
you a list of all availble options

get-content -<tab>

I can't recommend this PoSH add-on enough :-)

n
Kiron replied on 22-Jun-07 11:27 AM
Also in 'Windows PowerShell in Action' p.313

--
Kiron
mc replied on 22-Jun-07 03:30 PM
Not available in Win XP SP2 version of PowerShell:


PS C:\> get-command get-content| fl *


DLL              :
C:\WINDOWS\assembly\GAC_MSIL\Microsoft.PowerShell.Commands.Management\1.0.0.0__31bf3856ad364e35\Micr
osoft.PowerShell.Commands.Management.dll
Verb             : Get
Noun             : Content
HelpFile         : Microsoft.PowerShell.Commands.Management.dll-Help.xml
PSSnapIn         : Microsoft.PowerShell.Management
ImplementingType : Microsoft.PowerShell.Commands.GetContentCommand
ParameterSets    : {Path, LiteralPath}
Definition       : Get-Content [-Path] <String[]> [-ReadCount <Int64>]
[-TotalCount <Int64>] [-Filter <String>] [-Inclu
de <String[]>] [-Exclude <String[]>] [-Force]
[-Credential <PSCredential>] [-Verbose] [-Debug] [-Err
orAction <ActionPreference>] [-ErrorVariable <String>]
[-OutVariable <String>] [-OutBuffer <Int32>]

Get-Content [-LiteralPath] <String[]> [-ReadCount
[-Include <String[]>] [-Exclude <String[]>] [-Force]
[-Credential <PSCredential>] [-Verbose] [-Debug
] [-ErrorAction <ActionPreference>] [-ErrorVariable
nt32>]

Name             : Get-Content
CommandType      : Cmdlet


--
.............. All new, all fresh ..............
http://www.leedesmond.com/weblog/
Keith Hill [MVP] replied on 22-Jun-07 03:47 PM
Hmm, it is there on my XP SP2 system.  I also notice that your output does not
include the -Encoding or the -Delimiter parameters.

--
Keith
mc replied on 22-Jun-07 04:02 PM
Yes I noticed that too but was zooming in on the topic on hand (the -wait
parameter). Wonder what introduces the discrepency (missing 3rd party or
develpment tools, including the full .NET SDK)?


--
.............. All new, all fresh ..............
http://www.leedesmond.com/weblog/
erick calder replied to Shafik on 18-Aug-10 02:08 PM
forEach ($s in Get-Content my.txt -Wait) { echo $s }



doesn't work...