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.

3 comments:

  1. Substantially the article is really the best on this laudable topic. I concur with your conclusions and will eagerly look forward to your future updates.Just saying thank you will not just be enough for the wonderful lucidity in your writing.
    Vonage

    ReplyDelete
  2. would it be possible to let the inner * disepear ? So only the shape of the triangle remains ?

    ReplyDelete
    Replies
    1. Yes it is possible... here is the script ....
      http://tuxthink.blogspot.com/2012/12/creating-outline-of-triangle-shape-on.html

      Delete