Multiplying strings in bash script

前端 未结 5 2158
伪装坚强ぢ
伪装坚强ぢ 2020-12-16 20:59

I know that if I do print (\"f\" + 2 * \"o\") in python the output will be foo.

But how do I do the same thing in a bash script?

5条回答
  •  失恋的感觉
    2020-12-16 21:24

    That will do:

    printf 'f'; printf 'o%.0s' {1..2}; echo
    

    Look here for explanations on the "multiplying" part.

提交回复
热议问题