Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question 1) Briefly explain the script and lines (#1- #4 ): # #!/bin/sh # for i

ID: 3778153 • Letter: Q

Question

Question 1) Briefly explain the script and lines (#1- #4):
#
#!/bin/sh
#

for i in *                                             #1

     do

       if [ -d “$i” ]    #2

          then

            echo “$i”    #3

       fi

           done

echo “task complete.”                    #4

Question 2) Briefly explain the following lines: (#1- #5 )

#!/bin/bash

echo                            #1

                              

while [ "$var1" != "end" ]        #2

do

echo "Input variable #1 (end to exit) "

read var1                      #3

  echo "variable #1 = $var1"    #4

echo

done

exit 0                           #5

Answer Question 1 and 2 in details, thank you.

Explanation / Answer

Question1)

1. iterates through all the files or directories in the current directory.

2. checks if the current object is a directory.

3. prints the path of the directory.

4. prints "task complete"

Question 2)

1. prints a blank line

2. checks if var1 is not equal to end, then continue the while loop, else break the loop.

3. reads the value entered by user in the terminal into var1 variable.

4. prints "variable #1 = $var1" where $var1 is the value of the var1.

5. exit the program with successful execution.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote