excuting the following code

hi
i am trying the below code for the following

 
|_
|  |_
|  |_ |_
|  |_ |_ |_
|  |_ |_ |_ |_

and for this code also

*
* *
* * *
* * * *
* * * * *
!/bin/bash
#i = "*"
#read i
for((i="*";i<=5;i++))
do
 for((j="*";j<=$i;j++))
  do
   echo -n $i"*"
 done
 echo "*"
done

where am i going wrong????

Without checking syntax, I do not think you mean to start counting at "*" with your i & j variables. Perhaps starting to count at 1 would work better.
(Not sure how you i++ an asterisk.)

The i and j variable must be numeric only. It's not obvious why you are using a double loop.

$ cat x1
#!/bin/bash
line=""
for((i=0;i<=5;i++)); do
        line="$line|_"
        echo "$line"
done
$ ./x1
|_
|_|_
|_|_|_
|_|_|_|_
|_|_|_|_|_
|_|_|_|_|_|_
$
1 Like