Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Horizontal line on the console?

I want to print a horizontal line to the console. At the moment, I use -----, but there are small spaces between the single characters.

Is there a better character I might use?

_ is not a viable option, as it is not vertically centered. Is there something like a middlescore, strikethrough (or whatever it's name is) character?

like image 614
Golo Roden Avatar asked Nov 27 '13 10:11

Golo Roden


People also ask

What does a horizontal line indicate?

In more simple terms, a horizontal line on any chart is where the y-axis values are equal. If it has been drawn to show a series of highs in the data, a data point moving above the horizontal line would indicate a rise in the y-axis value over recent values in the data sample.

How do you print a horizontal line in Python?

Here the ASCII value u'\u2500' relates to hyphen without spaces at start and end. The \u specifies the following string is in extended ASCII form and 2500 denotes the ─ symbol. U+2550 is a double stroke ═ like =.


3 Answers

Hyphen         ---------------------
Underscore     _____________________
EM Dash        —————————————————————
Horizontal Bar ―――――――――――――――――――――
Horizontal Box ─────────────────────

There is a big list of characters to try over at wikipedia.

The horizontal box drawing character is my recommendation. It is designed for this purpose

like image 121
Gusdor Avatar answered Oct 20 '22 08:10

Gusdor


With bash, to display a horizontal rule the size of your window you can use:

printf %"$COLUMNS"s | tr " " "-"

With zsh, you could avoid the tr:

printf '—%.0s' {1..$COLUMNS} 

NOTE: I know this is not what OP wants, but it is what I think someone from Google could be seeking.

like image 24
Ulysse BN Avatar answered Oct 20 '22 08:10

Ulysse BN


Unicode character \u2500 solved it for me. According to Wikipedia it is for box drawings light horizontal, which is exactly what I need :-)

Thanks @Gusdor for pointing me to the correct Wikipedia article!

like image 20
Golo Roden Avatar answered Oct 20 '22 08:10

Golo Roden