kullu
April 1, 2011, 2:32pm
1
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????
joeyg
April 1, 2011, 3:07pm
2
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