Ahmad Nadaf
Ahmad Nadaf

Reputation: 31

Bash Shell Programing

I am trying to print the stars below on the screen using for or while loop. I don't know if I should treat as a string or what. If it is a string should I use foreach loop, just don't know where to start really.

******************
   ***********
     *******
       ***
        *

I am trying to get it to work even though I know it is wrong, but I am trying. Thanks for the advice.

#!/bin/bash

whilefunc() {
    echo "*************"
    echo"  ******  "
    echo"   ****   "
 }

i=2

while [ $i = 2 ]
do
    whilefunc
done

exit

Upvotes: 0

Views: 158

Answers (1)

nickjb
nickjb

Reputation: 1216

Any loop will do, and just escape the * with backslash i.e.

while [[ : ]]; do
  echo -e \*****
  echo -e  \***
  echo -e   \*
  # do whatever else you need to do
done

Upvotes: 1

Related Questions