Lab 3
Lab 3
OS LAB 3
IN LAB TASKS:
TASK 1:
TASK 2:
23k-0574 SYED ANFAS
23k-0574 SYED ANFAS
TASK 1:
23k-0574 SYED ANFAS
TASK 2:
23k-0574 SYED ANFAS
TASK 3:
23k-0574 SYED ANFAS
23k-0574 SYED ANFAS
TASK 4:
TASK 5:
#!/bin/bash
# Find and remove files older than the specified number of days
echo "Removing files older than $days days in $dir_path..."
find "$dir_path" -type f -mtime +$days -exec rm -f {} \;
echo "Files older than $days days have been removed."
TASK 6:
#!/bin/bash
# Create a file for the book with book name as the file name
book_file="$base_dir/$book_name.txt"
case $choice in
1)
create_book_directory
;;
2)
list_books
;;
3)
echo "Exiting the Book Manager."
exit 0
;;
*)
echo "Invalid option. Please try again."
exit 1
;;
esac
23k-0574 SYED ANFAS
TASK 7:
#!/bin/bash
# Function 3: List all hidden and unhidden files in the specified directory
list_files() {
if [ $# -ne 1 ]; then
echo "Usage: $0 <directory_path>"
return 1
fi
directory="$1"
# List all files, including hidden files (those starting with a dot)
ls -la "$directory"
}
case $choice in
1)
create_user_account
;;
2)
create_directories
;;
3)
read -p "Enter the directory path to list files: " dir_path
list_files "$dir_path"
;;
4)
echo "Exiting the script."
exit 0
23k-0574 SYED ANFAS
;;
*)
echo "Invalid option. Please try again."
exit 1
;;
esac