Book Image

Penetration Testing with the Bash shell

By : Keith Harald Esrick Makan
Book Image

Penetration Testing with the Bash shell

By: Keith Harald Esrick Makan

Overview of this book

Table of Contents (13 chapters)

Formatting the terminal output


Everything printed on your bash terminal is done by the cursor, which is just another component of your bash terminal you can control using very convenient shorthands. This section will cover how to control the color and basic formatting of the output printed on your terminal and you will also see some very cool tips and tricks in action later in this chapter.

To start off, let's talk about control sequences. Control sequences are character patterns that introduce special behavior for text being displayed on your terminal. These special characters always precede the output they format. Control sequences are often delimited by escape characters, and the one we are interested in is denoted by \e.

Using this control sequence, we can do pretty cool things; observe the following command line:

for colorcode in {93..88} {124..129};  do echo –en "\e[48;5;${colorcode}m \e[0m"; done

Here's a screenshot of the previous command in action:

Another example would be the following...