Is there a tail equivalent to -f on Windows?

Many times I find myself in a situation where I need to monitor the evolution of the log file in Windows. Is there a Linux equivalent

tail -f <filename> 

on a Windows terminal, preferably without installing external software ? Other SO posts talk about installing third-party programs.

+11
source share
4 answers

In Powershell, you can use Get-Content with the -Wait flag:

Get-Content filename.log -Wait

You can shorten Get-Content to gc . There is an answer to this question, proposed as a possible duplicate, which mentions this and some useful additional parameters - see fooobar.com/questions/24473 / .... I'm not sure if this is really a duplicate, as this question speaks of common Windows alternatives for Linux tail , not tail -f .

+14
source

Yes. You can use tail on windows, which is a small price to gain access to many GNU tools on windows, as well as tail . Since its kit is with git for windows , it is pretty much tested and stable.

First install git-bash from https://gitforwindows.org/

Then put git-bash in the Windows path and reboot the workstation:

setx path "%path%;C:\Program Files\Git\bin\"

Now you can use tail -n 20 -F logging_file.log to tail any file and display the last 20 lines.

If you are running Linux / Unix and want to constantly look at the logs, you can use the following command: ssh username@10.15.3.3 'bash -c "tail -n 20 -F /c/Users/username/Desktop/logging_file.log"'

+3
source

In Powershell, use:

 cat .\<file_name> -Tail 10 -Wait 
+2
source

I know what you said without an external program. But for people who have already installed the Windows Subsystem for Linux (WSL) and cannot make tail work properly in Ubuntu 16.04 LTS, I found this thread where someone found a workaround:

In case someone finds this via Google, it seems that the inotify support in WSL is limited to accessing the WSL file, not access to the win32 file, so you should tell tail not to use it:

 tail -f /mnt/c/path/to/file ---disable-inotify 

(yes, three dashes)

0
source

Source: https://habr.com/ru/post/1246478/


All Articles