Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Under your home directory, create a directory called Proj . 3 _ ID _ Sec# ( example Proj . 3 _ 1 2 3 0

Under your home directory, create a directory called Proj.3_ID_Sec#(example
Proj.3_1230123_sec1), and underneath it, do the following: Write a shell script called myproj that,
when executed, displays the following four choices:
(Your script should work on your own created files and
directories if they are needed)
Welcome Message
Write a shell script that prints a welcome message when the user logs in. It should display Good
morning/Good afternoon/Good evening, depending on when the user logs in.
.
When the myproj script is running, the welcome script displays the message automatically that displays the
following Menu, as shown below:
Good afternoon Muard Njoum
Please Choose one of the following options:
Directories:
1) Change Permission for All Directory.
2) Print all empty directories.
Files
3) Change Permission for All Files
4) Delete Duplicated files
Computer Science Department- Faculty of Engineering and Technology
Linux OS Lab - Comp 311
Due Date: Wednesday 05/06/2024, before 5:00 PM
Submission at Server
Projects 3. All answers must be from Labs (1-11) ONLY.
ANY STUDENT WHO USES A COMMAND NOT IN THE LAB MANUAL OR AI TOOLS
WILL NEVER BE GRADED, AND HE OR SHE WILL RECEIVE THE PROPER
ACADEMIC PUNISHMENT.
//)
()//
YOUR Work must be tested on your machine (Laptop) Before passing the
Project.
Report:
5) Count and display all files that contain the same word.
6) Count the number of files that have the same name inside different directories.
Exit 7) Display a Goodbye message to the host
Clarification of ALL Scripts
1. Directories:
1) Change Permission for All Directory.
Write a shell script, chmodAllDirectories, that will change the permissions of all directories inside a given leading
directory. The command chmodAllDirectories newpermission maindirecroty should set a new permission to all
directories inside a given leading directory. The script should set a new permission for all directories inside the given
directory.
If there is no argument or the main directory is not a directory, the script should print an error message to stderr and
exit.
Sample
chmodAllDirectories 600 students
2) Print all empty directories.
Write a shell script printEmptyDirectories maindirectory to print all empty directories as a full path. The
command printEmptyDirectories directory should only print all empty directories inside the given argument
directory.
Note: du command cannot be used in writing this script
If there is no argument or the main directory is not a directory, the script should print an error message to stderr and
exit.
Sample
./printEmptyDirectories /home/students/u1200735
/home/students/u1200735/mydir
/home/students/u1200735/dir1
....
/home/students/u1200735/test
...
2. Files:
3) Write a shell script, removeX, that will remove x permission of a given file from a given set of directories. The
command removeX file1 d1 d2 d3..dn removes the execution property of file1 inside that is laying inside d1 d2
d3...dn directories. If there is no argument, or if file1 is not a regular file or directory1 is not a directory, then the
script should print an error message to stderr and exit.
4) Delete all duplicate files
Write a shell script to deleteDuplicate that deletes all files (Keep one and remove the other) that are a copy of a
given file. The command deletes replication f1 f2... fn should remove all the files f2 through fn that are exact
copies of f1. Exact means that the file name and size are the same.
Sample:
(Assume that the midterm file in directory dir1 has another copy inside directory dir2)
./deleteDuplication dir1 dir2
File midterm has been deleted from the dir2 directory.
...
If there arent two arguments or dir1 and dir2 are not a directory, the script should print an appropriate error message
to stderr and exit.
3. Report:
5) Count and display all files that contain the exact word:
Write a countWord script that accepts as many arguments as possible (up to 8): the word to search for and a list
of directories. The script should display all files with their directories.
Your script should print an error if:
The first argument is not a type of regular file
The number of arguments is less than two.
Sample:
./countWord Computer Comp311 Comp433 Comp438
The Word Computer appears 4 times in the following Files with the
corresponding lines
/Comp311/midterm.doc line 10
/Comp311/resume.txt line 5
/Comp433/technology.txt. line 3
/Comp438/Myfiles.html line 25
6) Count the number of files that have the same name inside different directories.
Write a countFiles script that accepts two directories as arguments: the script should display all files wi

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

Does mind reading help or hinder communication?

Answered: 1 week ago