We help IT Professionals succeed at work.
Get Started

sell script

smitter
smitter asked
on
316 Views
Last Modified: 2010-04-21
I am new to unix; basically I want t creat an equilateral triangle of numbers. I am able to create a rightangled triangled triangle with the following code:
#!/bin/sh
max_no=0
echo "ENter any number"
read max_no
i=1
s=max_no
while [ $i -le $max_no ]
   do
   sp=""
     while [ $s -ge $i ]
    do
     sp=$sp""
     s=`expr $s - 1`
    done
    j=1

   while [ $j -le $i ]
    do
      sp=$sp$j
    j=`expr $j + 1`
     done
   echo $sp
   i=`expr $i + 1`
done        

The output is :
ENter any number
3
1
12
123
I need to know, where exactly I have to modify my code to create an equilateral triangle. However, the problem can be solved in linux, using for loop.
Rgds smitter
Comment
Watch Question
IT Consultant and Infrastructure Architect
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE