Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me fix these shell script errors Source code: #!/bin/bash prime_1=0 echo -n Enter the value of n: read n echo -n First

Please help me fix these shell script errors

Source code:

#!/bin/bash prime_1=0 echo -n "Enter the value of n: " read n echo -n "First $n prime numbers are: " echo -n "2 " counter=1 for((i=3;$counter=2;)) do if [ `expr $i % $j` -ne 0 ] ; then prime_1=1 else prime_1=0 break fi j=`expr $j - 1` done if [ $prime_1 -eq 1 ] ; then echo -n "$i " counter=`expr $counter + 1` fi i=`expr $i + 1`<>

done echo ""

Error screen:

image text in transcribed

./prime.sh line 10: (expr $i + 1: syntax error invalid arithmetic operator (error token is "$i+ 1") ./prime . sh: line 20: [: missing ]' ./prime.sh line 10: (expr $i +1: syntax erro invalid arithmetic operator (error token is "$i 1") ./prime . sh: line 20: [: missing ]' ./prime.sh line 10: (expr $i +1: syntax erro invalid arithmetic operator (error token is "$i 1") ./prime . sh: line 20: [: missing ]' ./prime.sh line 10: (expr $i +1: syntax erro invalid arithmetic operator (error token is "$i 1") ./prime . sh: line 20: [: missing ]' ./prime.sh line 10: (expr $i +1: syntax erro invalid arithmetic operator (error token is "$i 1") ./prime . sh: line 20: [: missing ]' ./prime.sh line 10: (expr $i +1: syntax erro invalid arithmetic operator (error token is "$i 1") ./prime . sh: line 20: [: missing ]' ./prime.sh line 10: (expr $i +1: syntax erro invalid arithmetic operator (error token is "$i 1") ./prime . sh: line 20: [: missing ]' ./prime.sh line 10: (expr $i +1: syntax erro invalid arithmetic operator (error token is "$i 1") ./prime . sh: line 20: [: missing ]' ./prime.sh line 10: (expr $i +1: syntax erro invalid arithmetic operator (error token is "$i 1") ./prime . sh: line 20: [: missing ]' ./prime.sh line 10: (expr $i +1: syntax erro invalid arithmetic operator (error token is "$i 1") ./prime . sh: line 20: [: missing ]' ./prime.sh line 10: (expr $i +1: syntax erro invalid arithmetic operator (error token is "$i 1") ./prime . sh: line 20: [: missing ]' ./prime.sh line 10: (expr $i +1: syntax erro invalid arithmetic operator (error token is "$i 1") ./prime . sh: line 20: [: missing ]' ./prime.sh line 10: (expr $i +1: syntax erro invalid arithmetic operator (error token is "$i 1") ./prime . sh: line 20: [: missing ]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions

Question

When should inventory be valued at its net realizable value?

Answered: 1 week ago

Question

How can we visually describe our goals?

Answered: 1 week ago

Question

What metaphors might describe how we work together?

Answered: 1 week ago

Question

What are some of the possible scenes from our future?

Answered: 1 week ago