Loading…
OS · Functions & patterns · Program 24 · In the record
shell script to print pyramid
1#!/bin/bash2 3echo "Enter the number of rows:"4read n5 6for (( i = 1; i <= n; i++ ))7do8 # Leading spaces9 for (( s = 1; s <= n - i; s++ ))10 do11 echo -n " "12 done13 14 # Stars15 for (( j = 1; j <= 2 * i - 1; j++ ))16 do17 echo -n "*"18 done19 20 echo21done5Enter the number of rows:
5
*
***
*****
*******
*********Run program 24 in your browser
bash · just-bash. Change the code or the input, run it, break it, and see what happens.