Question One . Create a count-down timer using shell script. The user sets the timer in minutes and seconds and the timer starts to tick. Once it is reached to zero, a message should be displayed on standard output. When the timer gets less than three minutes, then in each minutes, it should display the remaining time on standard output, i.e. “Three Minutes Remaining”, “Two Minutes Remaining”, “One Minute Remaining”.
The time has to be passed as a command line argument. Name your script “timer.sh”.
Example: A call “timer.sh 5,35” sets up a timer to 5 minutes and 35 seconds.
Question Two. Create a script to count the total size of all files in a given directory. The name of this directory has to be passed as command line argument and your script should work recursively, i.e. counts total size of all files in this directory and all directories(, sub, sub-sub, …) under this directory. Your output must include the number of counted files along with their total size, e.g. “Total files: 78, Total Size=78 MB”.
Question Three.
Develop a shell script that counts the total sum of all words used in all the ‘.txt’ files of the current directory and print the output in a file. Name this file as current date-time followed by “_report.txt. for instance, “Sun-Apr-3 14:04:13_report.txt”.
Question Two.
Suppose that there are two shell-scripts that produce output forever (infinite loop), namely one.sh and two.sh. For each of the following, write down the command(s) to accomplish the following:
a. Start both processes in the background
b. Bring “one.sh” processes to foreground
c. Move “two.sh” to foreground and “one.sh” to background
d. Move “two.sh” to background
e. Pause both processes in the background
f. Resume both processes in the background
g. Kill both processes in the background
Question Three
Develop a shell script that monitors any changes made to the size of each and every file in a specific directory at all times. The directory is passed as a command line argument. For any changes that is made to the size of any file, display a quick notification to standard output: “Modification has been made!”. Also, display the name of the file that has been modified.
Name your script “monitor.sh” and let it run in the background at all times. Then test your script to make sure that it works as desired.
Monitor.sh ~/Assignment_Two/Test_One
Hint:
You can use command ‘ls’ and store the results in a file, name it output_one.txt. Right after, run command ‘ls’ again, but this time, store the results in a different file output_two.txt. Now, compare these two files by using ‘diff’ command. Finally, place this algorithm in an infinite loop and let it work in the background forever.