← 返回命令列表

Linux command

print.zsh 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Print text

print "Hello"

Print to stderr

print -u2 "Error"

Print array elements

print -l ${array[@]}

Print with format

print -f "%s: %d\n" "Count" [5]

Push to directory stack

print -P "%~"

说明

print in zsh is an enhanced built-in command for text output that extends the ksh version with additional features. It supports printf-style formatting via -f, prompt expansion with -P (for displaying prompt escape sequences like %~ for the current directory), and can print array elements one per line with -l. The command provides reliable text output behavior compared to echo, whose handling of backslash escapes and option-like arguments varies across shells. Output can be directed to specific file descriptors with -u for writing to stderr or other open descriptors.

参数

-n
No newline.
-r
Raw mode.
-l
One argument per line.
-u _N_
File descriptor.
-f _FORMAT_
Printf-style format.
-P
Perform prompt expansion.

FAQ

What is the print.zsh command used for?

print in zsh is an enhanced built-in command for text output that extends the ksh version with additional features. It supports printf-style formatting via -f, prompt expansion with -P (for displaying prompt escape sequences like %~ for the current directory), and can print array elements one per line with -l. The command provides reliable text output behavior compared to echo, whose handling of backslash escapes and option-like arguments varies across shells. Output can be directed to specific file descriptors with -u for writing to stderr or other open descriptors.

How do I run a basic print.zsh example?

Run `print "Hello"` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -n do in print.zsh?

No newline.