Reputation:
Many times I find myself in the situation of having to follow the evolution of a log file on Windows. Is there an equivalent of the Linux
tail -f <filename>
command on a Windows terminal, preferably without having to install external software? Other SO posts talk about installing third-party programs.
Upvotes: 47
Views: 61798
Reputation: 31
Get-Content filename -Wait -tail 1
this worked for me, as said by nikobelia, just added the tail option and it works as expected!
Upvotes: 3
Reputation: 9670
I know you said without external program. But for the people who have already installed the Windows Subsystem for Linux (WSL) and they cannot make tail
work properly in Ubuntu 16.04 LTS I found this thread where somebody found a workaround:
In case anyone finds this through Google, it seems that inotify support in WSL is limited to WSL file accesses, not win32 file accesses, so you have to tell tail not to use it:
tail -f /mnt/c/path/to/file ---disable-inotify
(yes, three dashes)
Upvotes: 6
Reputation: 5350
Yes. you can use tail
on windows, which is a small price to pay to get access to a lot of GNU-tools on windows as well as tail
. Because its bundle with git for windows
, its pretty heavily tested and stable.
First install git-bash
from https://gitforwindows.org/
Next, put git-bash
on windows path using and reboot your workstation:
setx path "%path%;C:\Program Files\Git\bin\"
Now, you should be able to use tail -n 20 -F logging_file.log
to tail any file and show the last 20 lines.
If you are on Linux/Unix and you want to continuously see logs you can use the following command:
ssh [email protected] 'bash -c "tail -n 20 -F /c/Users/username/Desktop/logging_file.log"'
Upvotes: 7
Reputation: 4887
In Powershell you can use Get-Content with the -Wait flag:
Get-Content filename.log -Wait
You can shorten Get-Content to gc
. That question suggested as a possible duplicate has an answer which mentions this and some useful extra parameters -
see https://stackoverflow.com/a/188126. I'm not sure if it's really a duplicate, though, since that question is talking about general Windows alternatives to Linux tail
, rather than about tail -f
.
Upvotes: 51