PowerShell is a powerful tool and it enables the Windows servers to compete with the Shell and Linux command line features. One of the useful command in linux is tail which helps us to view the file as it gets updated mostly used to view the log files.
For instance, we start a service and we want to know if the service is coming up and check the errors in the log file, live without having to re-open the file.
Until I was introduced to this PowerShell command method, I was using either
notepad++ to tail the log files in Windows
PowerShell tail Command Get-Content
Powershell has a command named
Get-Content it exactly does the job as it was named after. It gets content from the file. This command has a
flag or attribute named
Tail which make it equivalent to the Linux tail command
Here is a simple tail command equivalent windows powershell Get-Content command.
Execution result of the preceding command is given below.
PowerShell tail -f Command Get-Content
the wonderful feature of tail is to watch for changes as it happens and see the live logs as it is getting updated. which is done using a
-f flag in Linux tail command
In windows, the same is achieved with another flag/option named
here is the windows PowerShell tail -f command equivalent Get-Content command
-Tail 10 -Wait
In fact, it is the same command as previous but an extra
-Wait has been added.
As shown in the screenshot you can see the cursor is at the end of the file it has not returned to terminal and monitoring (or) waiting for more lines to come.
Hope this article helped you to find the Linux Equivalent Windows find command in Powershell and now you know how to tail the log file in windows without using any special tools like baretail etc.
Signup for Exclusive "Subscriber-only" Content