Question: Write a Borne Again shell ( BASH ) script which receives a path as the input and calculates the number of each file type defined
Write a Borne Again shell BASH script which receives a path as the input and calculates the number of each file type defined in LinuxUnix file types in the given path. Name the script filestatics Here are some sample runs of the filestatics:
filestatics
You must enter a path:
Usage: filestatics pathname
filestatics foodir
foodir not found!
filestatics dev etc
You must enter a path:
Usage: filestatics pathname
filestatics dev
Here is the dev directory file type statistics:
OrdinaryBlockcharacterdirectorylinkpipesocket
filestatics etc
Here is the etc directory file type statistics:
OrdinaryBlockcharacterdirectorylinkpipesocket
Note that the above numbers might be different in your machine.
Bonus
You will receive bonus mark, if you also print the statistics for permission bits as well. Here is a sample output:
filestatics dev
Here is the dev directory file type statistics:
OrdinaryBlockcharacterdirectorylinkpipesocket
Here is the dev directory permission statistics:
ownerGroupOthers
r w x r w x r w x
Always check if the script has received the correct number of parameters and their orders based on the shown examples. If the user enters wrong parameter print an error message and notify the right usage format. In case of usage error or any other unusual error you need to exit with none zero value.
The output of your script should be nicely formatted. Use the tab character to properly format the output of your script.
If you create intermediate temporary files anywhere including in tmp remove them before your script ends.
Make sure, you have had enough comments to make your script readable and understandable. Also: Dont use the "awk" command or any others like it
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
