How do i make this script print out multiple boxes?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have this script that prints out a box frame with Asterisk signs, and I need to make it so that the script prints out multiple boxes under each other. How can I do it?
#!/bin/bash
#
echo -n "Please enter the amount of lines: "
read lines
echo -n "Please enter the amount of *: "
read sign
for((i = 1; i <= $lines; i++))
do
echo -n "$i "
if [ $i -eq 1 -o $i -eq $lines ]; then
for((j = 1; j <= $sign; j++))
do
echo -n "* "
done
else
echo -n "* "
for((j = 2; j < $sign; j++))
do
echo -n " "
done
echo -n "* "
fi
echo
done
#end
linux bash scripting
add a comment |Â
up vote
0
down vote
favorite
I have this script that prints out a box frame with Asterisk signs, and I need to make it so that the script prints out multiple boxes under each other. How can I do it?
#!/bin/bash
#
echo -n "Please enter the amount of lines: "
read lines
echo -n "Please enter the amount of *: "
read sign
for((i = 1; i <= $lines; i++))
do
echo -n "$i "
if [ $i -eq 1 -o $i -eq $lines ]; then
for((j = 1; j <= $sign; j++))
do
echo -n "* "
done
else
echo -n "* "
for((j = 2; j < $sign; j++))
do
echo -n " "
done
echo -n "* "
fi
echo
done
#end
linux bash scripting
Just run the code in a loop? Also, this question, or a similar one, came up recently. Is it homework? Are you later supposed to add a star in the center of the box like this person wanted? Don't output individual characters in loops, it's horribly inefficient.
â Kusalananda
May 29 at 6:59
pretty much yes, i keep overthinking to get the answer.
â MargusL
May 29 at 8:53
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have this script that prints out a box frame with Asterisk signs, and I need to make it so that the script prints out multiple boxes under each other. How can I do it?
#!/bin/bash
#
echo -n "Please enter the amount of lines: "
read lines
echo -n "Please enter the amount of *: "
read sign
for((i = 1; i <= $lines; i++))
do
echo -n "$i "
if [ $i -eq 1 -o $i -eq $lines ]; then
for((j = 1; j <= $sign; j++))
do
echo -n "* "
done
else
echo -n "* "
for((j = 2; j < $sign; j++))
do
echo -n " "
done
echo -n "* "
fi
echo
done
#end
linux bash scripting
I have this script that prints out a box frame with Asterisk signs, and I need to make it so that the script prints out multiple boxes under each other. How can I do it?
#!/bin/bash
#
echo -n "Please enter the amount of lines: "
read lines
echo -n "Please enter the amount of *: "
read sign
for((i = 1; i <= $lines; i++))
do
echo -n "$i "
if [ $i -eq 1 -o $i -eq $lines ]; then
for((j = 1; j <= $sign; j++))
do
echo -n "* "
done
else
echo -n "* "
for((j = 2; j < $sign; j++))
do
echo -n " "
done
echo -n "* "
fi
echo
done
#end
linux bash scripting
edited May 29 at 7:46
Marco
750516
750516
asked May 29 at 6:43
MargusL
31
31
Just run the code in a loop? Also, this question, or a similar one, came up recently. Is it homework? Are you later supposed to add a star in the center of the box like this person wanted? Don't output individual characters in loops, it's horribly inefficient.
â Kusalananda
May 29 at 6:59
pretty much yes, i keep overthinking to get the answer.
â MargusL
May 29 at 8:53
add a comment |Â
Just run the code in a loop? Also, this question, or a similar one, came up recently. Is it homework? Are you later supposed to add a star in the center of the box like this person wanted? Don't output individual characters in loops, it's horribly inefficient.
â Kusalananda
May 29 at 6:59
pretty much yes, i keep overthinking to get the answer.
â MargusL
May 29 at 8:53
Just run the code in a loop? Also, this question, or a similar one, came up recently. Is it homework? Are you later supposed to add a star in the center of the box like this person wanted? Don't output individual characters in loops, it's horribly inefficient.
â Kusalananda
May 29 at 6:59
Just run the code in a loop? Also, this question, or a similar one, came up recently. Is it homework? Are you later supposed to add a star in the center of the box like this person wanted? Don't output individual characters in loops, it's horribly inefficient.
â Kusalananda
May 29 at 6:59
pretty much yes, i keep overthinking to get the answer.
â MargusL
May 29 at 8:53
pretty much yes, i keep overthinking to get the answer.
â MargusL
May 29 at 8:53
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
If you just want the number of boxes as an input, it is just:
#!/bin/bash
#
echo -n "Please enter the amount of lines: "
read lines
echo -n "Please enter the amount of *: "
read sign
echo -n "Please enter the amount of boxes: "
read boxes
for ((h = 1; h <= $boxes; h++))
do
for((i = 1; i <= $lines; i++))
do
echo -n "$i "
if [ $i -eq 1 -o $i -eq $lines ]; then
for((j = 1; j <= $sign; j++))
do
echo -n "* "
done
else
echo -n "* "
for((j = 2; j < $sign; j++))
do
echo -n " "
done
echo -n "* "
fi
echo
done
done
#end
Not sure whether this is what you want though, because if you wrote your code you should have probably figured it out.
i keep overthinking and i was curious to find out a simple way
â MargusL
May 29 at 8:54
Thank you for your help, now i understand and possibly do not overthink.
â MargusL
May 29 at 8:57
No problem. I guess this was the simplest way to extend exactly what you were doing in the way you were doing it. Feel free to accept the answer if you think it was what you needed :)
â myradio
May 29 at 9:00
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
If you just want the number of boxes as an input, it is just:
#!/bin/bash
#
echo -n "Please enter the amount of lines: "
read lines
echo -n "Please enter the amount of *: "
read sign
echo -n "Please enter the amount of boxes: "
read boxes
for ((h = 1; h <= $boxes; h++))
do
for((i = 1; i <= $lines; i++))
do
echo -n "$i "
if [ $i -eq 1 -o $i -eq $lines ]; then
for((j = 1; j <= $sign; j++))
do
echo -n "* "
done
else
echo -n "* "
for((j = 2; j < $sign; j++))
do
echo -n " "
done
echo -n "* "
fi
echo
done
done
#end
Not sure whether this is what you want though, because if you wrote your code you should have probably figured it out.
i keep overthinking and i was curious to find out a simple way
â MargusL
May 29 at 8:54
Thank you for your help, now i understand and possibly do not overthink.
â MargusL
May 29 at 8:57
No problem. I guess this was the simplest way to extend exactly what you were doing in the way you were doing it. Feel free to accept the answer if you think it was what you needed :)
â myradio
May 29 at 9:00
add a comment |Â
up vote
0
down vote
accepted
If you just want the number of boxes as an input, it is just:
#!/bin/bash
#
echo -n "Please enter the amount of lines: "
read lines
echo -n "Please enter the amount of *: "
read sign
echo -n "Please enter the amount of boxes: "
read boxes
for ((h = 1; h <= $boxes; h++))
do
for((i = 1; i <= $lines; i++))
do
echo -n "$i "
if [ $i -eq 1 -o $i -eq $lines ]; then
for((j = 1; j <= $sign; j++))
do
echo -n "* "
done
else
echo -n "* "
for((j = 2; j < $sign; j++))
do
echo -n " "
done
echo -n "* "
fi
echo
done
done
#end
Not sure whether this is what you want though, because if you wrote your code you should have probably figured it out.
i keep overthinking and i was curious to find out a simple way
â MargusL
May 29 at 8:54
Thank you for your help, now i understand and possibly do not overthink.
â MargusL
May 29 at 8:57
No problem. I guess this was the simplest way to extend exactly what you were doing in the way you were doing it. Feel free to accept the answer if you think it was what you needed :)
â myradio
May 29 at 9:00
add a comment |Â
up vote
0
down vote
accepted
up vote
0
down vote
accepted
If you just want the number of boxes as an input, it is just:
#!/bin/bash
#
echo -n "Please enter the amount of lines: "
read lines
echo -n "Please enter the amount of *: "
read sign
echo -n "Please enter the amount of boxes: "
read boxes
for ((h = 1; h <= $boxes; h++))
do
for((i = 1; i <= $lines; i++))
do
echo -n "$i "
if [ $i -eq 1 -o $i -eq $lines ]; then
for((j = 1; j <= $sign; j++))
do
echo -n "* "
done
else
echo -n "* "
for((j = 2; j < $sign; j++))
do
echo -n " "
done
echo -n "* "
fi
echo
done
done
#end
Not sure whether this is what you want though, because if you wrote your code you should have probably figured it out.
If you just want the number of boxes as an input, it is just:
#!/bin/bash
#
echo -n "Please enter the amount of lines: "
read lines
echo -n "Please enter the amount of *: "
read sign
echo -n "Please enter the amount of boxes: "
read boxes
for ((h = 1; h <= $boxes; h++))
do
for((i = 1; i <= $lines; i++))
do
echo -n "$i "
if [ $i -eq 1 -o $i -eq $lines ]; then
for((j = 1; j <= $sign; j++))
do
echo -n "* "
done
else
echo -n "* "
for((j = 2; j < $sign; j++))
do
echo -n " "
done
echo -n "* "
fi
echo
done
done
#end
Not sure whether this is what you want though, because if you wrote your code you should have probably figured it out.
edited May 29 at 8:55
answered May 29 at 6:57
myradio
1885
1885
i keep overthinking and i was curious to find out a simple way
â MargusL
May 29 at 8:54
Thank you for your help, now i understand and possibly do not overthink.
â MargusL
May 29 at 8:57
No problem. I guess this was the simplest way to extend exactly what you were doing in the way you were doing it. Feel free to accept the answer if you think it was what you needed :)
â myradio
May 29 at 9:00
add a comment |Â
i keep overthinking and i was curious to find out a simple way
â MargusL
May 29 at 8:54
Thank you for your help, now i understand and possibly do not overthink.
â MargusL
May 29 at 8:57
No problem. I guess this was the simplest way to extend exactly what you were doing in the way you were doing it. Feel free to accept the answer if you think it was what you needed :)
â myradio
May 29 at 9:00
i keep overthinking and i was curious to find out a simple way
â MargusL
May 29 at 8:54
i keep overthinking and i was curious to find out a simple way
â MargusL
May 29 at 8:54
Thank you for your help, now i understand and possibly do not overthink.
â MargusL
May 29 at 8:57
Thank you for your help, now i understand and possibly do not overthink.
â MargusL
May 29 at 8:57
No problem. I guess this was the simplest way to extend exactly what you were doing in the way you were doing it. Feel free to accept the answer if you think it was what you needed :)
â myradio
May 29 at 9:00
No problem. I guess this was the simplest way to extend exactly what you were doing in the way you were doing it. Feel free to accept the answer if you think it was what you needed :)
â myradio
May 29 at 9:00
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f446614%2fhow-do-i-make-this-script-print-out-multiple-boxes%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Just run the code in a loop? Also, this question, or a similar one, came up recently. Is it homework? Are you later supposed to add a star in the center of the box like this person wanted? Don't output individual characters in loops, it's horribly inefficient.
â Kusalananda
May 29 at 6:59
pretty much yes, i keep overthinking to get the answer.
â MargusL
May 29 at 8:53