1. Basic Shell Programs (Assignment - 1)
1. Use commands to do the following:-
a. Listing files and directories.
b. Showing, creating and concatenating files.
c. Coping files, Renaming files and deleting files.
d. Making directories ,changing directories, Removing directories.
e. Make the following directory tree:-
KGEC
|--------------------|-------------------------|----------------------|----------------------|
CSE IT ECE ME EE
|
|----------First_Year
|----------Second_Year
|----------Third_Year
|----------Fourth_Year
2. Write a Shell script that will display the date, time, username and current directory.
3. Write a Shell script that will display the current working shell.
4. Write a Shell script that will display information regarding the users who are logged in
along with their column headings.
5. Write a Shell script that will take some command line arguments and displays the name
of the shell script file, total number of arguments and the value of those arguments.
6. Write a Shell script that will take a name as command line arguments and displays the
following: Input: sh program_6.sh Anirban Output: Hello Anirban! Welcome to UNIX.
7. Write a simple shell script myscript.sh that takes a path of a directory as a command line
argument and list all files and folders inside the given directory.
Run the script as: sh myscript.sh /cse/sb2/os_course/week_4/docs
8. Write a Shell script that will take two numbers as command line arguments and displays
their sum, difference, product and division.
9. Write a Shell script that will display the shell’s PID.
10. Write a Shell script that will display the exit status of the last program to exit (generally
programs return a 0 upon success ).
11. Write a Shell script that will display the current username.
12. Write a Shell script that will take username as argument and displays whether he/she is
logged in or not.
13. Modify the program 5 by using a switch-case that will take arguments in the following
form: sh program_10.sh 2 + 3 Result: 5
sh program_10.sh 10 - 2 Result: 8
sh program_10.sh 10 / 2 Result: 5
sh program_10.sh 2 * 3 Result: 6
sh program_10.sh 2 # 3 Unknown Operation
14. Write a shell script using switch case that displays the week day(MONDAY as 1) taking
only an integer as input.
Example: sh program_11.sh 2
Output: Day is TUESDAY