From the course: Learning Bash Scripting

Unlock this course with a free trial

Join today to access over 24,800 courses taught by industry experts.

Formatting and styling text output

Formatting and styling text output - Bash Tutorial

From the course: Learning Bash Scripting

Formatting and styling text output

Let's move back to working with text for a while. One option offered by the echo built-in is -e, which tells Bash to interpret escaped characters or sequences, which can be used to enhance text output. Escaped sequences can represent special characters like Tab, Newline, or the Bell. And they can be used to change the color of text in the terminal as well. When we write scripts, we'll often want to format text to line it up in columns or indent it. And the tab character plays a role there. For example, I can make some column headers with tabs between them and then provide another line with the same number of tabs. I'll write echo -e "Name\t\t, for two tab characters, and number. I'll write a semicolon, and I'll write another echo statement here. echo -e, my name, two tab characters, and 123. I'll run this. And because of the tab characters, my text lines up in easy-to-see columns. Another special character, the newline character, tells the terminal to start putting the following text…

Contents