Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I multiply a character N times using bash?

I just want to echo spaces until it fills the size of the terminal.
I can just write spaces between the quotation marks but it takes time and also it looks bad.

I tried simple things like

a=" "*100 or a=(" "*100) & echo $a

but it won’t work.
Is there any way like Space(100) or a better way than typing spaces.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Like this, using Perl:

perl -sE 'say " " x $col' -- -col=$COLUMNS

Or the most simple:

printf '%*s' $COLUMNS " "

The variable $COLUMNS is the number of columns in your shell.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading