How to repeat a dash (hyphen) in shell

前端 未结 7 864
北海茫月
北海茫月 2020-12-31 10:10

How can I repeat the character - n times in shell? I have read and tried this, but this does not work for -. It throws error invalid option

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-31 10:44

    This has been my goto for years... not AIX friendly though. Change the last character to change the repeating character which makes up the line

    printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' _
    

提交回复
热议问题