I am observing an odd behaviour in PowerShell. I can echo hi
but I can't echo.
to get a newline:
It does work in Command Prompt:
One answer suggests that the .ps1
file might have a BOM in it. I tried converting my script to ANSI but this did not help, and as you can see from the above it still fails even without a script file.
Another answer suggests that there might be a file named echo.
in the same directory, but there isn't.
How can I fix echo.
or otherwise how can I echo a newline please?
Running just echo
without the .
halts and prompts for input.
Running write hi
works but write.
fails, in the same way as echo.
The same goes for Write-Output
and Write-Host
.
I have tried manually installing the latest version of PowerShell (v7.4.1) but this did not help.
After much searching I've just found a working solution.
This doesn't work:
But this does:
I am guessing that
echo.
is only implemented incmd
, notps
.You could also use a function, if you like, like so:
function echo. { echo "" }
, after that you can use the "command"echo.
.