Raj Bhul EC3236 Programming Report PDF
Raj Bhul EC3236 Programming Report PDF
Raj Bhul EC3236 Programming Report PDF
Extension certification:
This assignment has been given an extension and is now due on _______________.
Lecturer’s Signature: _____________
1
ACKNOWLEDGEMENT
I sincerely thank Mr. Nirdosh Bista, my lecturer, for his continuous support, direction, and
attention to detail during the course of the assignment, all of which contributed to its
successful conclusion. Mr. Bista, in addition to his busy schedule, offered priceless advice,
helpful criticism and encouragement.
I also want to express thanks to all of the materials that helped me finish this task. The books,
research papers, websites, and software tools that I have used have been extremely helpful in
both deepening my understanding and making the execution of the task easier.
Lastly, I would like to express my gratitude to all individuals who directly or indirectly
contributed to the accomplishment of this assignment. Your support and assistance have been
invaluable, and I am truly grateful for your contributions.
Thank you all for your invaluable support and assistance during this assignment.
Table of Content
Introduction........................................................................................................................................4
Introduction to Each Scenario..........................................................................................................5
Snapshot of Each Script: Visualizing File Management Operations............................................7
Test Case and Output Screenshot..................................................................................................12
2
Conclusion........................................................................................................................................19
References.........................................................................................................................................20
Marking Scheme..............................................................................................................................21
Introduction
Understanding how to manage files efficiently is at the heart of this task. By learning file
management, we enhance our ability to navigate and manipulate data, which is vital for
systems programming. Bash scripting serves as our tool for automating tasks and making file
management processes smoother.
3
Making tasks we do a lot easier by automating them.
Handling files and folders without messing things up.
Making sure the information we're giving the computer makes sense.
Writing code that's easy for anyone to understand and use.
The script I'm making should be easy for anyone to use. It should let users do things like
making new folders, seeing what's inside a folder, creating empty files, writing stuff in files,
and deleting files or folders. I have to make sure it doesn't mess up and accidentally delete
something important, so I need to double-check everything.
To make the script, I'll need to make sure it asks the user questions in a simple way and
checks if the answers make sense. It's also important to add little notes in the script to explain
what each part does, so anyone reading it can understand. And when the user is done, the
script should close nicely without causing any problems.
Once I finish this assignment, I'll be much better at scripting in Bash. These skills will come
in handy in lots of jobs, like managing computer systems or making software. I'm excited to
complete this assignment and feel more confident about taking on similar tasks in the future.
The assignment at hand requires the development of a bash script designed to execute
fundamental file management tasks within a Linux environment. These tasks are crucial for a
range of professionals, spanning from system administrators to developers, and anyone who
regularly engages with files in Linux systems.
1. Creating a Directory:
Users are prompted to input the desired directory name.
The script checks if the directory already exists, providing appropriate feedback.
Additionally, it ensures that the directory name input is not null.
4
The script displays files and subdirectories within the specified directory in an
organized manner.
Similar to directory creation, the script validates that the directory name input is not
null.
6. Deleting a File:
Users initiate deletion of a specified file via system prompt.
The script confirms user intent before deletion and adeptly handles potential errors.
Additionally, it verifies that the filename input is not null before proceeding with
deletion.
7. Deleting a Directory:
Users can remove a specified directory and its contents recursively.
The script confirms user intent before deletion and appropriately manages
encountered errors.
Non-null directory name input is validated before proceeding with deletion.
Each operation in the script initiates interaction by prompting users to input the necessary
directory or file name essential for executing the action. This interactive approach ensures
effective engagement between the script and the user, guiding them seamlessly through each
step of the process. By soliciting user input through prompts, the script facilitates clear
communication and empowers users to navigate file management tasks with ease. This user-
centric design enhances the overall usability of the script, promoting a smooth and intuitive
experience for individuals interacting with it.
5
Snapshot of Each Script: Visualizing File Management Operations
1. Creating a Directory
6
3. Creating an Empty File
7
5. Displaying the Content of a File
6. Deleting a File
7. Deleting a Directory
8
8. Option Section of the Script
9. Performing the Task Based on the Chosen Alternative Section of the Script
9
10. Loop Section of the Script
10
If directory “Padmashree” already exist display message directory already exists.
11
3. Test Case: Create Empty File
Input: Filename: "System.txt"
Expected Output: The script should create a new empty file named "System.txt" and
provide a success message.
12
X
If the user enters 'N' or any other input, the script should cancel the deletion
operation and display a corresponding message.
13
7. Test Case: Deleting Directory with Confirmation
Input:
Directory Name: "Padmashree"
Confirmation: Yes/No
Expected Output:
The script should prompt the user with a confirmation message before proceeding
with the deletion of the directory " Padmashree" and its contents.
The confirmation message should ask the user to confirm the deletion by typing 'Y'
for yes or 'N' for no.
Upon entering 'Y' for confirmation, the script should delete the director "
Padmashree" and its contents recursively, displaying a success message confirming
the deletion.
If the user enters 'N' or any other input, the script should cancel the deletion
operation and display a corresponding message.
14
8. Test Case: Input Validation During Selection
Input:
Input your selection: 9
Expected Output: The system ought to present a prompt requesting the user to input a
valid option, followed by the display of available choices for the user to select from
again.
10. Test Case: Validation for Non-Empty File and Directory Names
Input:
Directory/File Name: "Padmashree" or "System.txt"
Expected Output:
15
The script should detect and display an error message if the user input for
directory or file name is left empty.
Conclusion
Finally, by creating a Bash script, this assignment has given a thorough overview of all the
functions that are necessary for file management in a Linux system. I now have a better grasp
of the nuances involved in efficiently managing data on a system level thanks to the process
of creating, listing, modifying, and removing files and folders.
By breaking down each operation into manageable steps and incorporating user prompts for
input, the script ensures clear communication and user engagement throughout the process.
Additionally, incorporating validation checks for input ensures the script's robustness and
16
guards against potential errors or unintended actions, thereby enhancing its reliability and
usability.
Through this exercise, I've honed my skills in Bash scripting, reinforcing the importance of
clarity, organization, and error handling in code development. Moreover, this assignment has
underscored the significance of user-centric design in creating scripts that are intuitive and
accessible to a wide range of users, regardless of their technical expertise.
Moving forward, I feel more confident in my ability to tackle similar tasks in systems
programming and beyond. The skills acquired through this assignment will undoubtedly
prove invaluable in various professional settings, whether in managing computer systems,
developing software, or engaging in other technical endeavours. Overall, this experience has
been instrumental in broadening my understanding of file management and enhancing my
proficiency in Bash scripting.
References
#LINUX, 2023. freecodecamp.org. [Online]
Available at: https://www.freecodecamp.org/news/bash-scripting-tutorial-linux-shell-script-
and-command-line-for-beginners/
[Accessed 17 March 2024].
Albing , C. & Vossen, J., 2022. Bash Idioms. 1st ed. United States of America: by O'Reilly
Media, Inc., .
Albing, C. & Vossen, J., 2018. Bash Cookbook. 1st ed. United States of America: O' Relliy
Media, Inc.,.
Deitel, P. & Deitel, H., 2013. C How To Program. 7th ed. Delhi: Pearson Education, Inc.,
publishing as Prentic Hall .
17
Marking Scheme
18
Creativity and 5 Implementation of additional features or creative
Additional approaches to the problem beyond the basic
Features requirements.
Documentation 10 As per documentation requirement.
19