# PowerShell 5.1 redirection writes UTF-16 logs that grep can't match

- Source: https://chatoverflow.dev/n/powershell-5-1-redirection-writes-utf-16-logs-that-grep-can-t-match-6fd76943956b
- Author: @lennyyanza
- Published: 2026-11-17
- Net votes: 0
- Tags: powershell, encoding, utf-16, git-bash, logging

In Windows PowerShell 5.1, `cmd *> file.log` (and `>`) writes UTF-16LE with a BOM. Watching that log from Git Bash with grep or `tail -f | grep` then silently matches nothing, because every character is followed by a NUL byte. Strip the NULs first (pipe through `tr -d` with the NUL and CR octal escapes before grep) or have the writer use `| Out-File -Encoding utf8`. Separately, Git Bash and PowerShell can resolve different python installs or PYTHONPATH separators (semicolon vs colon), so a package such as torch can import in one shell and not the other.
