Multiplying strings in bash script

前端 未结 5 2155
伪装坚强ぢ
伪装坚强ぢ 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:14

    You can create a function to loop a string for a specific count and use it in the loop you are executing with dynamic length. FYI a different version of oter answers.

      line_break()
        {
            for i in `seq 0 ${count}`
            do
              echo -n "########################"
            done
        }
    
        line_break 10
    

    prints: ################

提交回复
热议问题