ITWS2 Assignment - 1 Shell Scripting
ITWS2 Assignment - 1 Shell Scripting
Shell Scripting
1. Write a Bash script, average_files.sh, to find all the files and
directories with size larger than or equal to the average file size of
the directory. Say, the directory /home/student has 6 files/directories
with size in parentheses " x(100) y (10) z (100) p (100) q(20) r(66),
your program average_files.sh /home/student" will list "x z p r" since
the size of each of the four files/directories is larger than the average
file size of 66(note that the average is rounded off) .
2. Write a Bash script, num_sort.sh, that can sort a list of command line
parameters in ascending order. There is no limit to the number of
arguments passed as list parameters. For example, your command
will look something like:
$ num_sort.sh 8 27 9 -2 7 92 -9 0 and type enter.
Your program will return: -9 -2 0 7 8 9 27 92
Use only basic commands and array. Do not use any built-in
commands that sort array.
4. Write a Bash script, userlist.sh, to list all the users on the system.
The command to run will look like:
$ userlist.sh
Return:
USER #1 = root
USER #2 = bin
USER #3 = daemon
...
USER #33 = bozo
Hint: Use the contents of the file /etc/passwd and awk.
E.g.