If you call baretail.exe on a command line, you can give it paths to log files as parameters. Instead of doing that every time, you can script out paths in batch files. Below is a simple example of calling baretail.exe with paths to three log files on the same server.
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.
Baretail Alternative
- BareTail is a real-time file viewing utility. Like the Unix tail -f utility, it can be used to view the end of a growing file. It is ideal for viewing application traces or server logs in real time, as they are generated.
- I have been using BareTail for low-footprint log reading, and it works wonderfully. In particular, I like that it can consume very large large files, detect changes to those files, all without consuming much memory at all.
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 baretail
or 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 Wait
here is the windows PowerShell tail -f command equivalent Get-Content command
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.
Conclusion
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.
Cheers
Sarav
Follow us on Facebook or Twitter
For more practical videos and tutorials. Subscribe to our channel
Find me on Linkedin My Profile
For any Consultation or to hire us hello@gritfy.com
If you like this article. Show your Support! Buy me a Coffee.
Baretail Linux
Signup for Exclusive 'Subscriber-only' Content
Baretail Free Download
More from Middleware Inventory
Baretail Weekend
- Powershell Find String in file - How to use windows find command
If you are here, Then you might have had a similar requirement I had, which is to find a specific file across multiple directories and to grep or Search for a string present in that file. ( more like what we do with xargs in Linux) I am a Linux…
- Netstat command windows - Usage and Examples
Introduction Like Linux, Windows does have a netstat command and it can come handy when you are in need of network-related monitoring and troubleshooting. Consider you have any of the following requirement How to find who or which process owns the port in Windows Server To see how many HTTP/DB…
- Arbitary File Download Vulnerability
Overview Some websites may provide file viewing or download functionality because of business needs. If you do not limit user from viewing or downloading files, a malicious user may attempt to view or download any file from your server. Attackers may construct malicious requests to download sensitive files from the…
- Stop, Start, Restart Windows Service Command Line - How to
Windows Service management through the command line is really a good approach when you want to manage plenty of services and perform day to day actions like stop, start and restart I think you would agree, If I say GUI is fun for entry-level but when it comes to performing the…
- ansible search for string in file or check if string exists in file
The Objective of this post is to show how to search for a string in a file with ansible. ansible provides various ways to accomplish the same. We will cover, three major ways to search for a string in a file. Lineinfile module Using the Shell module and grep command…