简体   繁体   English

bash 相当于 python ("=" * { n }) 中的字符串乘法

[英]bash equivalent of string multiplication in python ("=" * { n })

Is there a bash equivalent to python's elegant string multiplication ?是否有相当于 python 的优雅字符串乘法bash

>>> "=" * 8
'========'

You can use printf.您可以使用 printf。

printf '=%.0s' {1..8}

you can try something like this:你可以尝试这样的事情:

myString=$(printf "%10s");echo ${myString// /=} 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM