如何在 Bash 中重复一个字符? [英] How can I repeat a character in Bash?
本文介绍了如何在 Bash 中重复一个字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎么能用 echo
做到这一点?
How could I do this with echo
?
perl -E 'say "=" x 100'
推荐答案
没有简单的方法.但例如:
No easy way. But for example:
seq -s= 100|tr -d '[:digit:]'
# Editor's note: This requires BSD seq, and breaks with GNU seq (see comments)
或者可能是符合标准的方式:
Or maybe a standard-conforming way:
printf %100s |tr " " "="
还有一个 tput rep
,但至于我手头的终端(xterm 和 linux),他们似乎不支持它:)
There's also a tput rep
, but as for my terminals at hand (xterm and linux) they don't seem to support it:)
这篇关于如何在 Bash 中重复一个字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文