Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Draw a horizontal line from dash character occupying the full width of a terminal in bash

Tags:

I need a command that will draw a horizontal "line" in the terminal. The line must be exactly the width of the terminal long (regardless of a current terminal width) and consist of a dash character (although a unicode symbol for a horizontal line can be also used).

It is better if it can be colored.

I need to use it like this:

echo some text
drawline
echo more text

And the output would look something like this:

echo some text
---------------------------------------------------------------------------------
echo more text
like image 290
exebook Avatar asked Mar 13 '17 11:03

exebook


People also ask

What does the dash mean in bash?

In man bash , at the end of the single-character options there is:- -- A -- signals the end of options and disables further option processing.

How do I print a line in bash?

Printing Newline in Bash The most common way is to use the echo command. However, the printf command also works fine. Using the backslash character for newline “\n” is the conventional way.


1 Answers

Try with:

echo some text
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -
echo some text
like image 96
Zumo de Vidrio Avatar answered Oct 20 '22 04:10

Zumo de Vidrio