0% found this document useful (0 votes)
6 views3 pages

Bash Script for Directory Breakdown Exam

This document outlines the requirements for a practical exam involving the creation of a bash script to organize text files into smaller directories. The script must demonstrate correct logic and flow, even if minor syntax errors exist, and must be executable from any location. Specific pre-requisites, restrictions, and tips for completing the task are provided, along with submission guidelines.

Uploaded by

hewohe3859
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Bash Script for Directory Breakdown Exam

This document outlines the requirements for a practical exam involving the creation of a bash script to organize text files into smaller directories. The script must demonstrate correct logic and flow, even if minor syntax errors exist, and must be executable from any location. Specific pre-requisites, restrictions, and tips for completing the task are provided, along with submission guidelines.

Uploaded by

hewohe3859
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Sample practical

Kindly note that this is a sample for the practical exam. The actual exam will
probably be longer and you will be required to create multiple bash scripts.

Important sidenote:

Please note that the content,logic and flow of your script holds the most
weight rather than the actual output. Therefore, even if your code has a
slight syntax error and does not produce an output, but the logic and flow is
correct, you will still score a high mark.

Estimated time to complete this task: 30-45 mins. Please note that the practical
exam will be either 90 or 120 minutes (not decided yet).

Task -
You have one large directory, that has 1000 text files named [Link] to
[Link] . You are required to break down this large directory into 10 smaller
directories where each directory has 100 files. These smaller directories that you
will create must be named small_txt_directory1 to small_txt_directory10
where each of these directories must have 100 text files. These directories MUST
be created under the home directory.

Your solution must be provided as a bash script that can be executed from
anywhere as a command (i.e you do not need pass the full path of the script to
execute it). Everything regarding manipulating this large directory MUST be
done through the bash script unless explicitly told otherwise.

The directory that you will manipulate/break down is large_txt_directory


which should be created under the home directory (read the pre-requisites)

Pre-requisites - the following can be done outside the script.


In your home directory create a directory called 'scripts_sample_finalw23',
the script you create MUST be created under this directory.
Script MUST be named breakdown_txt_dir.sh .
Under home directory create a folder called large_txt_directory .
Change to the directory large_txt_directory and execute the following
touch file{1..1000}.txt . Important, these files MUST be under
large_txt_directory .

Restrictions (read very carefully) -


Extremely important: At the beginning of the script You MUST have these 3
lines regarding your info (commented)
# name - firstname lastname
# id - your id
# lab day - Sunday/Tuesday/Thursday

The small directories created through your script MUST be named


small_txt_directory1 to small_txt_directory10 and MUST be under the
home directory and not large_txt_directory
NO user other than student should be able to read,write or execute the
script. In other words, only the user 'student' should be able to read,write
and execute this script. (this can be done outside the script)
You can safely assume that everything under the large_txt_directory is a
text file name [Link] (where is 1,2,3, etc). So you don't need to check if its a
file or directory when listing the contents under the large_txt_directory .
Each directory does not need have to the respective order of files. I.e. small
dir1 does not need to have files file1 to file100, all that matters is that it has
100 text files.
Hard-coding the creation of these sub-directories will result in 90% marks
deduction. That is, use loops to create and manipulate the directories, not
create dir1, create dir2,create dir3 and so on.

Tips (Such tips MAY not be provided in the final exam):


To copy to a directory , the destination directory must exist. Make sure to
check if the destination directory exists before copying to it.
Syntax for incrementing a numerical variable ((counter++))
You might need two counters, one for counting how many times you copied
a file and one for the destination directory.
Incase you forgot the options for the if conditions execute man test in the
terminal.

Submission guidelines
follow the submission template to submit the required screenshots.

You might also like