Skip to content
shellmap

tailOutput the last lines of a file across all 5 shells

Equivalents in every shell

Bashunix
tail -n 10 file
Zshunix
tail -n 10 file
Fishunix
tail -n 10 file
PowerShellwindows
Get-Content file -Tail 10

Add `-Wait` to follow.

cmd.exewindows
powershell -Command "Get-Content file -Tail 10"

cmd has no native tail; shell out to PowerShell.

Worked examples

Follow a growing log file

Bash
tail -f app.log
PowerShell
Get-Content app.log -Wait -Tail 10

Show last 50 lines

Bash
tail -n 50 app.log
PowerShell
Get-Content app.log -Tail 50

Tail multiple files

Bash
tail -f *.log
PowerShell
Get-ChildItem *.log | ForEach-Object { Get-Content $_ -Tail 5; Write-Host '--' }

Gotchas

  • `Get-Content -Wait` polls; on very high-throughput files it can drop lines compared to GNU `tail -f` (which uses inotify on Linux).
  • cmd alone has no tail equivalent — you must shell out to PowerShell, install GNU coreutils, or use WSL.
  • `tail -F` (capital) on GNU tail re-opens the file if rotated; `-Wait` in PowerShell does not handle log rotation gracefully.

WSL & PowerShell Core notes

pwsh`Get-Content -Tail N` works on every pwsh platform. For very large files (multi-GB log files) it streams from the end, so it remains fast — unlike `Get-Content file | Select-Object -Last N` which reads the whole file first. Use `-Tail` for any "last N lines" job on a sizable log.
WSLTailing a file on `/mnt/c/...` from WSL works but is materially slower than tailing a file in the WSL filesystem (`~/`) because DrvFs polls Windows file changes rather than relying on inotify — `tail -f /mnt/c/logs/app.log` updates with a 1–2s lag and can miss lines on bursty writes. For low-latency log following, either keep the log inside `~/` or run `Get-Content -Wait` from Windows-side PowerShell.

Common tasks using tail

Related commands