Assignment 2.B Unix ITW1 2025
Assignment 2.B Unix ITW1 2025
B
1. Write a script to calculate word frequency for all text files in a directory.
2. Write a script to find the longest word in a file and its length.
3. Write a script to merge two sorted files into a single sorted file without using sort.
4. Write a script to find all palindromic words in a file and count their occurrences.
5. Write a script to find all anagrams of a word from a file.
6. Write a script to find the top N processes consuming the most CPU and calculate their
total CPU usage.
7. Write a shell script to:
a. Recursively list all files and directories starting from the current directory.
b. Display each file/directory along with its permissions, size, and last modified date.
c. Count the total number of files and directories separately.
d. Identify the largest file (based on size) and display its name, size, and
permissions.
e. Save the detailed output to a log file and display the summary (counts and largest
file) on the terminal.
8. Write a shell script to calculate and display the size of directories up to a given depth.
The script should:
a. Accept the base directory and depth as input from the user.
b. Exclude specific directories (provided as a list of directory names or patterns by
the user).
c. Include an option to display the sizes in human-readable format (e.g., KB, MB,
GB).
d. Create a detailed log file with directory names, their sizes, and depth levels.
e. Optionally sort the output by directory size in ascending or descending order
based on user input.
f. Handle symbolic links gracefully, avoiding infinite loops caused by circular links.
9. Write a shell script to recursively apply specific permissions to all files, directories, and
symbolic links starting from a base directory. The script should:
a. Allow the user to specify separate permissions for files, directories, and symbolic
links.
b. Skip hidden files and directories unless explicitly enabled by a command-line flag.
c. Generate a log file detailing all changes made, including the old and new
permissions for each file/directory.
d. Support dry-run mode to display what changes would be made without actually
modifying any permissions.
10.Write a shell script to monitor system resources and alert administrators when any
partition exceeds a given disk usage threshold percentage (e.g., 80%) and also the total
memory used by processes owned by a specific user exceeds a specified limit (e.g., 500
MB). The script should:
a. Accept thresholds for both disk usage and memory usage as inputs.
b. Display the disk partitions exceeding the threshold, along with their current
usage.
c. Identify the user processes contributing to the memory usage and display their
details (e.g., PID, memory used).
d. Log the results to a file with timestamps.