Search

Creating a triangle of characters in the terminal

Here is a script that crates a triangle of what ever character we choose.
The triangle gets created right at the center in the terminal.
The script uses tput along with various loops to create the triangle.

triangle.sh



Save the script and give it execute permission



Execute the script as follows



You should see a triangle of * as below on the terminal.



You can enter any number of rows and any character to create the triangle, the only limit being the number of rows should not exceed one screen of the terminal, it can not create a shape that goes beyond one screen.

Follow by Email