Question
In a linux operating system(I'm using SSH secure shell) use the shell script to display the drawing your first and last name initial pattern. I
In a linux operating system(I'm using SSH secure shell) use the shell script to display the drawing your first and last name initial pattern. I created a script and went to the nano editor to edit the script. Code was given to me but each time I was running it there is a syntax error and it is supposed to displayed a diamond pattern. This is the code that was given. I found online that someone put a very similair code to this one with a few changes. Changing MAX_NO to MAX in each part of the code and no ";" before the "then".
#!/bin/bash
MAX_NO=0
echo -n "Enter Number between (5 to 9) : "
read MAX_NO
if ! [ $MAX_NO -ge 5 -a $MAX_NO -le 9 ] ; then
echo "WTF... I ask to enter number between 5 and 9, Try Again"
exit 1
fi
clear
for (( i=1; i<=MAX_NO; i++ )) do for (( s=MAX_NO; s>=i; s-- ))
do
echo -n " "
done
for (( j=1; j<=i; j++ )) do echo -n " *" done echo "" done
###### Second stage ###################### for (( i=MAX_NO; i>=1; i-- ))
do
for (( s=i; s<=MAX_NO; s++ ))
do
echo -n " "
done
for (( j=1; j<=i; j++ ))
do
echo -n " *"
done
echo ""
done
With correcting the code it runs without an error but instead of a proper diamond pattern it displays a pattern like this one.
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*
How am I supposed to make that pattern a proper diamond pattern. Please let me know how to correct this and have the code run without an error. Also what am I supposed to do to make it ask someone to put their intials instead of "*" to make the diamond pattern.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started