0% found this document useful (0 votes)
70 views2 pages

Linux Bash Homework Solutions

This document contains 7 assignments completed by Atreya Dey with SR No. 09908 on 22/01/2016. The assignments include programs to calculate squares of numbers, copy a file into folders using for loops, evaluate integer and floating point expressions, create and rename files in nested folders using conditionals, and calculate the factorial of 20 using a while loop.

Uploaded by

Atreya Dey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views2 pages

Linux Bash Homework Solutions

This document contains 7 assignments completed by Atreya Dey with SR No. 09908 on 22/01/2016. The assignments include programs to calculate squares of numbers, copy a file into folders using for loops, evaluate integer and floating point expressions, create and rename files in nested folders using conditionals, and calculate the factorial of 20 using a while loop.

Uploaded by

Atreya Dey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Assignment 1

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.

You might also like