Answered step by step
Verified Expert Solution
Question
1 Approved Answer
OPERATING SYSTEM SHELL SCRIPTING IN LINUX QUESTION No. 02 [20] Write a script that displays a main menu and perform tasks based on the input
OPERATING SYSTEM
SHELL SCRIPTING IN LINUX
QUESTION No. 02 [20] Write a script that displays a main menu and perform tasks based on the input value. Valid input values = {1, 2, 3, 4, exit). The different options 1,2,3,4 will display the output as follow: 1. Input a filename from user and display permissions of that particular file. Then invert the permissions e.g. If permissions were r-x change them to -w-. Then again display the updated permissions of that file. [5] 2. Input a filename and a string and search it in the file. Output the lines of file where that string is found. But if the string contains a dot(.) it means any character can fill the place. For example: [5] string = c.t = {cat, cot, c t.} 3. Create a file dummy.txt and add the content of all the files in the current directory to dummy. But copy the content in such a way that if files in current directory = {fl, 12, f3, f4, ..., fn}. Then copy first N lines of files at even location {f2, f4.) and last N lines of files at odd location {f1.f3,. }}. Input value of N from user. [5] 4. Input a filename from user and check modified date of that file. If modified date is greater than 24 hours from the current time change the modified date to current date. Along with displaying the output on terminal, maintain a log file that contains the information of the script. Format of the log file is given below: [5] Format of the log File Option 01 selected at date and time File name: filename.bet Permissions of filename.txt: Show permissions Permissions changed Updated Permissions of filename.txt: Show permissions Option 02 selected at date and time Filename: filename.txt String: string Output all the lines in filename where string is found. Option 03 selected at date and time Files at odd location: f1, f. f5 Files at even location: 12,4 Dummy.txt is created and N lines of each file copied in it. Option 04 selected at date and time Filename: filename.txt Current modified date: date Modified time updated or not Option exit Script terminated at date and time. 2 QUESTION No. 02 [20] Write a script that displays a main menu and perform tasks based on the input value. Valid input values = {1, 2, 3, 4, exit). The different options 1,2,3,4 will display the output as follow: 1. Input a filename from user and display permissions of that particular file. Then invert the permissions e.g. If permissions were r-x change them to -w-. Then again display the updated permissions of that file. [5] 2. Input a filename and a string and search it in the file. Output the lines of file where that string is found. But if the string contains a dot(.) it means any character can fill the place. For example: [5] string = c.t = {cat, cot, c t.} 3. Create a file dummy.txt and add the content of all the files in the current directory to dummy. But copy the content in such a way that if files in current directory = {fl, 12, f3, f4, ..., fn}. Then copy first N lines of files at even location {f2, f4.) and last N lines of files at odd location {f1.f3,. }}. Input value of N from user. [5] 4. Input a filename from user and check modified date of that file. If modified date is greater than 24 hours from the current time change the modified date to current date. Along with displaying the output on terminal, maintain a log file that contains the information of the script. Format of the log file is given below: [5] Format of the log File Option 01 selected at date and time File name: filename.bet Permissions of filename.txt: Show permissions Permissions changed Updated Permissions of filename.txt: Show permissions Option 02 selected at date and time Filename: filename.txt String: string Output all the lines in filename where string is found. Option 03 selected at date and time Files at odd location: f1, f. f5 Files at even location: 12,4 Dummy.txt is created and N lines of each file copied in it. Option 04 selected at date and time Filename: filename.txt Current modified date: date Modified time updated or not Option exit Script terminated at date and time. 2Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started