无法通过 Zsh 在两列中回显 az

发布于 2024-07-21 08:01:05 字数 149 浏览 2 评论 0原文

为了说明目的,我需要在两列中打印以下序列

a-z

,其中包含从 a 到 z 的字母,以便它们位于 13 个字符的列中。

如何将从 a 到 z 的字符回显到两列中?

I need to print the following sequence for illustration purposes in two columns

a-z

which has alphabets from a to z such that they are in 13-character columns.

How can you echo the characters from a to z into two columns?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

小苏打饼 2024-07-28 08:01:05

非常好的 Stephan,

避免使用循环输入 az 怎么样?

for i in {a..z}; do echo -n $i; done | sed -e 's/\(.\)\(.\)/\1 \2\n/g'

Very nice Stephan,

How about avoiding to type a through z with a loop?

for i in {a..z}; do echo -n $i; done | sed -e 's/\(.\)\(.\)/\1 \2\n/g'
紅太極 2024-07-28 08:01:05

我确信存在更好的解决方案,但我会尝试一下:

$ echo "abcdefghijklmnopqrstuvwxyz" | sed -e 's/\(.\)\(.\)/\1 \2\n/g'
a b
c d
e f
g h
i j
k l
m n
o p
q r
s t
u v
w x
y z

Better solutions exist, I'm sure, but I'll give it a shot:

$ echo "abcdefghijklmnopqrstuvwxyz" | sed -e 's/\(.\)\(.\)/\1 \2\n/g'
a b
c d
e f
g h
i j
k l
m n
o p
q r
s t
u v
w x
y z
太阳哥哥 2024-07-28 08:01:05

您的问题没有指定如何分配两列中的字符,因此这里有一个替代答案:

prompt> paste <(echo "abcdefghijklm" | sed 's/\(.\)/\1\n/g' ) <(echo "nopqrstuvwxyz" | sed 's/\(.\)/\1\n/g')
a       n
b       o
c       p
d       q
e       r
f       s
g       t
h       u
i       v
j       w
k       x
l       y
m       z

prompt>

Your question did not specify how to distribute the characters in the two coloumns, so here is an alternative answer:

prompt> paste <(echo "abcdefghijklm" | sed 's/\(.\)/\1\n/g' ) <(echo "nopqrstuvwxyz" | sed 's/\(.\)/\1\n/g')
a       n
b       o
c       p
d       q
e       r
f       s
g       t
h       u
i       v
j       w
k       x
l       y
m       z

prompt>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文