macOS zsh在末尾打印换行符



<COW]"向右,还添加了一个换行符。我不想有换行,以便下一个打印的东西打印在同一行(但左对齐)。我该怎么做呢?我见过的所有文档都说printf没有添加换行符,但如果你在下面的第二行添加两倍或三倍,很明显它添加了>

col=$(tput cols)
printf '%*s'  $col "[COW]"
printf "do you see that %s over there:" "cow"

注:zsh 5.8 (x86_64-apple-darwin20.0)

printf没有添加换行符。终端仿真器正在滚动,因为您键入的内容超出了行尾。

您应该在第一条消息的末尾写一个回车,这样它就会返回到该行的开头。

col=$(tput cols)
printf '%*sr'  $col "[COW]"
printf "do you see that %s over there:" "cow"

最新更新