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

Lab Assignment, Exams, Universities, Lab Work

This laboratory assignment focuses on shell programming, specifically using loop control structures and file/string test options. It includes tasks such as calculating overtime pay, displaying command line arguments, checking file sizes, and managing files and directories based on user input. The assignment aims to enhance understanding of shell scripting through practical exercises involving various programming concepts.

Uploaded by

mardiblbiswajit
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)
3 views2 pages

Lab Assignment, Exams, Universities, Lab Work

This laboratory assignment focuses on shell programming, specifically using loop control structures and file/string test options. It includes tasks such as calculating overtime pay, displaying command line arguments, checking file sizes, and managing files and directories based on user input. The assignment aims to enhance understanding of shell scripting through practical exercises involving various programming concepts.

Uploaded by

mardiblbiswajit
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

Laboratory Assignment: 5

Subject: Design of Operating Systems


Subject code: CSE 4049

Assignment 5: Shell Programming using Loop Control Structure, File test


options and string test options.

Objective of this Assignment:


 To learn the use of different loop control structures (for, while, until) in shell
programming.
 To familiarize with the file and string test options in shell programming.
1. Write a program to calculate overtime pay of 10 employees. Overtime is paid at the rate of
Rs. 12.00 per hour for every hour worked above 40 hours. Assume that employees do not
work for fractional part of an hour.
2. Write a shell script darg that will display all the command line arguments passed during
its execution, in the following format:
Argument 1: value
Argument 2: value

3. Write a shell script fsize that can take multiple file names as its argument and display their
size in the following format:
File name Size in byte
file1 24
4. Write a shell script nvcat that will display a message to enter a filename and then display
the content of the file in the following format:
Filename: File1

...................
.....................
Then it will display another message “Do you want to display another file 1/0”.
According to the entered choice it will display a message to enter a filename and then
display the content of the file otherwise exit. The process will continue till choice entered
is 1. [Implement it using while loop and then using until loop]
5. Write a shell script which will received any number of filenames as arguments. The shell
script should check whether every argument supplied is a file or a directory. If it is a
directory it should be appropriately reported. If it is a filename then name of the files as
well as the number of lines present in it should be reported.
6. Write a shell script dfile2 that will display the name of all directories and non-executable
files present in the current working directory.
7. Write a shell script which displays a list of all files present in the current working
directory to which you have read, write and execute permission.

8. Write a shell script nvcp that will receive multiple file names as arguments. If even
number of files are supplied then the first file should get copied to the second file, the third
file should get copied to fourth file and so on. If odd numbers of files are supplied then no
copying should take place and an error message should be displayed.

9. Write a shell script which will receive any number of filenames as arguments. The shell
script should check whether such files already exist. If they do, then it should be reported.
If these file do not exist then check if a sub directory called mydir exists in the current
directory. If it doesn’t exist then it should be created and in it the files supplied as
arguments should get created. If mydir already exists then it should be reported along
with the number of files that are currently present in mydir.

You might also like