Linux Bash Homework Solutions

Embed Size (px)

Citation preview

  • 7/25/2019 Linux Bash Homework Solutions

    1/2

    Assignment 1

    Atreya DeySR No. - 09908

    22/01/2016

    Answer 1

    This program produces the square of four numbers starting from 1. The forloop runs over 1 to 5 and computes the square of the numbers and printsthem.

    Answer 2

    A for loop runs over the counter 1,2,3 and 4. All the required folders are

    made and the pre-made file abc is copied into these folders.

    Answer 3

    The given integer expressions are evaluated using the given syntax with theprovided values.

    Answer 4

    The given floating point expressions are evaluated using the given syntaxwith the provided values.

    Answer 5

    Three nested for loops are used in the range 1-4 to create the folders 1.1.1to 4.4.4. The if conditional checks for the presence of the directory of a pre-defined name and if present the file abc in the directory is renamed to cdfusing mv command.

    1

  • 7/25/2019 Linux Bash Homework Solutions

    2/2

    Answer 6

    Once again three nested loops are used in the range 1-4 to create the folders1.1.1 to 4.4.4. Now, the if conditonal checks for the presence of a folder of apre-defined name and then removes that folder if it is presnt.

    Answer 7

    The factorial of 20 is calculated in this example using an iterative technique.The iterator i=20 is decreased by unity in every step using a while loop andthe product of all the integers from i to 1 is accumulated in another variable

    fact. Then fact is printed as the factorial.

    2