Linux Bash Homework Solutions
Linux Bash Homework Solutions
Atreya Dey
SR No. - 09908
22/01/2016
Answer 1
This program produces the square of four numbers starting from 1. The for
loop runs over 1 to 5 and computes the square of the numbers and prints
them.
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 the
provided values.
Answer 4
The given floating point expressions are evaluated using the given syntax
with the provided values.
Answer 5
Three nested for loops are used in the range 1-4 to create the folders 1.1.1
to 4.4.4. The if conditional checks for the presence of the directory of a predefined name and if present the file abc in the directory is renamed to cdf
using mv command.
1
Answer 6
Once again three nested loops are used in the range 1-4 to create the folders
1.1.1 to 4.4.4. Now, the if conditonal checks for the presence of a folder of a
pre-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 and
the product of all the integers from i to 1 is accumulated in another variable
fact. Then fact is printed as the factorial.