Search for question
Question

Objectives: Demonstrate understanding of BASH environment variables. Utilize file and directory management commands. Apply file editing techniques and manage file permissions. Employ pipes and redirection in scripts. Leverage positional parameters and conditional statements in script creation. Instructions: You are tasked with creating a BASH script that adheres to the following specifications. You are to capture screenshots at various stages of your script execution and submit these along with your script file to Canvas. Part 1: Environment Variables and Directory Management Create a script named env_directory_manager.sh. At the beginning of your script, define an environment variable called PROJECT_DIR which should hold the path to a directory named bash_project in your home directory. Use an if condition to check if the bash_project directory exists. If it does not exist, your script should create it. Inside the bash_project directory, create a subdirectory named reports. Capture a screenshot showing the successful execution of these commands and the existence of the directories. Part 2: File Creation and Permission Management Inside the bash_project directory, create a file named summary.txt. Write the current date and time into this file using the appropriate Linux commands. Change the permissions of this file so that only the owner can read and write to the file, but not execute it. Capture a screenshot of the file permissions before and after the change. Part 3: Utilizing Pipes and Positional Parameters Modify your script to accept one positional parameter: a keyword for searching. Use a combination of grep, sort, and other commands to search for this keyword in all .txt files within the reports subdirectory. Then, sort the results alphabetically and redirect them to a file named filtered_reports.txt in the reports directory. Ensure your script checks if the keyword was provided; if not, print a user-friendly error message. Capture a screenshot demonstrating this part working with an actual keyword. Part 4: Boolean Logic and File Editing Add a feature to your script that checks if today is either Saturday or Sunday (hint: use the date command and if statements combined with logical operators). If it is the weekend, append a message "It's the weekend! No reports today." to the summary.txt file. Otherwise, append "Regular weekday, get back to work!". Capture a screenshot showing the contents of summary.txt after running your script on both a weekday and a weekend. Submission Details: Combine all your screenshots into a single PDF document. Submit the PDF along with your env_directory_manager.sh script to Canvas. Ensure your script is well-commented, explaining each section and command for clarity. Grading Criteria: Correctness of the script in terms of fulfilling the requirements. Ability to effectively use environment variables, file and directory commands, and conditional statements. The clarity and quality of your screenshots. Code readability and comments. Please make sure to test your script thoroughly before submission. Remember, clear and concise comments in your script will help not just the graders, but also your future self. Good luck