How to create a script in Linux that makes a pyramid of asterisks with the pattern 1, 3, 5, 7, 9, 11, 13, 15, 17 centered -
i'm trying write shell script print pyramid of asterisks this:
* *** ***** ******* ********* *********** ************* *************** *****************
below attempt far. when run it, errors arithmetic expression required. doing wrong?
for (( = 1; <= n, i++ )); (( k = i; k <= n, k++ )); echo -ne " " done (( j = 1; j <= 2 * - 1, j++ )); echo -ne "*" done echo done
the syntax of arithmetic for-loop uses 2 semicolons, not semicolon , comma:
for (( = 1; <= n; i++ ));
(the individual components may contain commas — example, i++, j++
expression increments both i
, j
— has no specific relevance for
.)
Comments
Post a Comment