OSY Report
OSY Report
Micro-Project Report
Institute Code: 0078
Academic Year: 2023-24 Program: Computer Technology
Course: Operating System (OSY) Course Code: 22516 Scheme: I
Semester: 5 Class: TYCM-Lin Date of Report: / / 2023
2.0 Rationale:
The rationale behind this project lies in addressing the need for an efficient and user-friendly solution to manage
and explore files in command-line environments. With manual file organization often proving time-consuming and
error-prone, this project aims to simplify and streamline the process. By providing users with the ability to
categorize files by size and type through a well-designed shell script, we intend to automate file management,
ultimately enhancing productivity and file organization for a wide range of users.
● Aim:
The aim of this project is to enhance file management and exploration in a command-line
environment by developing a versatile shell script.
● Objectives:
Develop functions to categorize files and directories by size and type, providing users with
efficient ways to organize their data.
● Benefits:
This shell script simplifies file management in the command line, offering efficient categorization
by size and type, improving productivity, and providing clear data insights for users.
4.0 Course Outcomes Achieved (COs): ( Specify COs which are achieved in micro project e.g. CO502)
CO502.1: Install operating system and configure it.
CO502.2: Use operating system tools to perform various functions.
CO502.6: Apply file management techniques.
5.0 Literature Review:
In the domain of command-line file management, existing systems predominantly involve manual sorting and basic
command-line tools, such as ‘ls,’ ‘find,’ and ‘du.’ While these methods offer versatility, they lack automation and
user-friendly interfaces, making them challenging for non-technical users. The proposed shell script seeks to
address these limitations by providing a user-friendly menu interface and automating file categorization by size and
type, aiming to enhance efficiency and reduce errors in the file management process. This system strikes a balance
between automation and user customization, bridging the gap between existing systems’ strengths and their
limitations, ultimately offering a more efficient and streamlined approach to command-line file management.
7.0 Actual Resources used: (Resources such as Computer/equipment/machine/devices, OS, software, raw material, etc.)
S. No. Name of Resource/material Specifications Qty Remarks
# MENUS SECTION
## MAIN MENU
main-menu(){
clear
while true; do
echo "==== FiDir - File Sort with Filters ===="
echo "1. Sort and display"
echo "2. Filter and display"
echo "3. exit"
echo "========================================"
read -p "Enter your choice: " choice
clear
case $choice in
1) sort-menu
;;
2) filter-menu
;;
3) exit 0
;;
*) echo "Invalid choice, try agin... "
sleep 2
clear
;;
esac
done
}
## SORT MENU
sort-menu(){
clear
while true; do
echo "=================================================="
echo "1. Display files and directories by size"
echo "2. Display files by file type"
echo "3. Sort files/directories by date created"
echo "4. List files/directories by last modified date"
echo "5. Back"
echo "6. Exit"
echo "=================================================="
read -p "Enter your choice: " schoice
clear
case $schoice in
1) display_files_by_size
;;
2) display_files_by_type
;;
3) display_files_by_date_created
;;
4) display_files_by_last_modified
;;
5) main-menu
;;
6) exit 0
;;
*) echo "Invalid choice. Please try again."
;;
esac
done
}
## FILTER MENU
filter-menu(){
clear
while true; do
echo "=================================================="
echo "1. Filter with file type"
echo "2. Filter by permission"
echo "3. Back"
echo "4. exit"
echo "=================================================="
read -p "Enter your choice: " fchoice
clear
case $fchoice in
1) read -p "Enter the file type: " file_type
list_files "$file_type"
;;
2) read -p "Enter permission name (eg. write): " perm
list_files_by_permission $perm
;;
3) main-menu
;;
4) exit 0
;;
*)
echo "Invalid choice. Please select a valid option."
;;
esac
done
}
for file in *; do
if [ -f "$file" ]; then
file_size=$(du -h "$file" | cut -f1)
last_modified_date=$(stat -c "%y" "$file")
printf "%-16s %-20s %s\n" "$file_size" "${last_modified_date%% *}" "$file"
elif [ -d "$file" ]; then
dir_size=$(du -h -s "$file" | cut -f1)
last_modified_date=$(stat -c "%y" "$file")
printf "%-16s %-20s %s\n" "$dir_size" "${last_modified_date%% *}" "$file"
fi
done | sort $sort_option
}
list_files_by_permission() {
local permission_name="$1"