Answers:
您可以执行以下操作:
ls | cut -c1-20 | columns -W "${COLUMNS:-80}"

(这是columns有s从GNU AUTOGEN)。要么:
ls | cut -c1-20 | column -c"${COLUMNS:-80}"
使用column对BSD系统或如发现bsdmainutils在Debian或其衍生物。
zsh 还支持在列中打印内容,因此您可以定义以下功能:
setopt extendedglob
c() print -rC$[COLUMNS/(($1)+2)] -- "${(M)@[2,-1]##?(#c0,$[$1])}"
并将其用作:
c 20 *.txt
要在列中打印列表txt文件,将其截断为20个字符。
为了使它更疯狂,您可以添加:
command_not_found_handler() {(($1)) && c "$@"}
这样,您还可以执行以下操作:
20 *
甚至:
8+8 *
