write-output — Send objects down the pipeline — echo for objects across all 5 shells
Equivalents in every shell
echo "hello"Builtin. Adds a trailing newline by default; pass `-n` to suppress. `printf` is the POSIX-portable alternative when you need format strings or no implicit newline (`printf "%s" "$x"`).
echo "hello"Builtin. Same `-n` flag as bash. Zsh also has `print` (`-l` for newline-separated array, `-r` for raw / no interpretation) which is more flexible than `echo` for complex output.
echo "hello"Builtin. Fish `echo` does NOT interpret backslash escapes by default (a deliberate departure from bash) — pass `-e` to enable, or use `printf` for portable escape handling.
Write-Output "hello"Aliased as `echo` and `write`. Emits objects to the SUCCESS pipeline stream — the value can be piped to the next cmdlet, captured by `=`, or assigned. `Write-Host` is different: it bypasses the pipeline and writes directly to the host UI (you cannot pipe or capture it).
echo helloBuilt-in. cmd `echo` does NOT need quotes around arguments — quotes are emitted as part of the output. `echo.` prints an empty line; `echo off` / `echo on` control batch-file echoing.
Worked examples
Print a literal string
echo "hello world"echo hello worldWrite-Output "hello world"echo hello worldEmit a value into a pipeline for further processing
echo 42 | bcWrite-Output 1, 2, 3 | Measure-Object -SumPrint without a trailing newline
echo -n "no newline"echo -n "no newline"Write-Host "no newline" -NoNewlineset /p "=no newline" <nulGotchas
- `Write-Output` writes to the SUCCESS stream (stream 1) — it can be piped, captured with `$x = Write-Output ...`, or redirected with `>`. `Write-Host` writes to the HOST UI (stream 6 in pwsh 5+) — it cannot be piped or captured by `=` (`$x = Write-Host 'hi'` makes `$x = $null` and prints `hi` directly). Use `Write-Output` when you want a chainable value; reserve `Write-Host` for ANSI-coloured banners aimed at the user.
- Multiple arguments are passed as an ARRAY: `Write-Output 1 2 3` emits THREE objects, not the string `'1 2 3'`. To get a single string, join first: `Write-Output ('hello world')` or `Write-Output "$x $y"`.
- Implicit output: the LAST line of a function body or script that produces a value (without `Write-Output`) is implicitly returned via the pipeline. `function f { 42 }` and `function f { Write-Output 42 }` behave identically — but the implicit form trips bash users who expect `return 42` semantics.
- `echo` is a pwsh alias for `Write-Output` on Windows. On Linux/macOS pwsh hosts the alias is ALSO `Write-Output`, but the system `/bin/echo` is on PATH — if you specifically want the Unix tool (with its `-e` / `-n` quirks), use `& /bin/echo` to bypass the alias.
- `Write-Output -NoEnumerate` is needed when emitting a single array as ONE object. Without it, `Write-Output @(1,2,3)` unrolls to three pipeline items; with it, the receiver sees one `[object[]]` of length 3. This bites scripts that round-trip arrays through a function.