{"id":445,"date":"2024-04-21T18:05:23","date_gmt":"2024-04-21T18:05:23","guid":{"rendered":"https:\/\/sites.wp.odu.edu\/odu-student-template\/?p=445"},"modified":"2024-04-21T18:05:23","modified_gmt":"2024-04-21T18:05:23","slug":"assignment-8","status":"publish","type":"post","link":"https:\/\/sites.wp.odu.edu\/odu-student-template\/2024\/04\/21\/assignment-8\/","title":{"rendered":"Assignment 8"},"content":{"rendered":"\n<p>Step-1: Use vi or nano editor to write your script (Ex, nano lkopa.sh) for the following tasks.<br>Step-2: After saving the script, save and exit out of the editor and make the script executable by adding execute permission ( chmod +x lkopa.sh)<br>Step-3: Run your script using .\/lkopa.sh<\/p>\n\n\n\n<p>Task A (Correct script (25 points) + result\/output after executing the script (25 points)- Conditional Statement Write a shell script using nano or vi editor (eg, nano lkopa.sh) like below, that performs the following task:<\/p>\n\n\n\n<ol>\n<li>Add the Shebang (#!\/bin\/bash) as the first line in your script.<\/li>\n\n\n\n<li>Read a number using read function<\/li>\n\n\n\n<li>Using if statement, check if the input number is less than 10, then print the message \u201cInput number is greater than 10.<\/li>\n\n\n\n<li>If the number is not greater than 10, then print the message, \u201cInput number is not greater than 10.<\/li>\n<\/ol>\n\n\n\n<p><\/p>\n\n\n\n<p>Task B (Correct script (25 points) + result\/output after executing the script (25 points) &#8211; Shell Script to Create a new file Write a shell script using nano or vi editor (eg, nano lkopa.sh) like below, that performs the following task:<\/p>\n\n\n\n<ol>\n<li>Add the Shebang (#!\/bin\/bash) as the first line in your script.<\/li>\n\n\n\n<li>Reads the name of the file to check for a filename that exists.<\/li>\n\n\n\n<li>Check whether the given input is a directory or regular file.<\/li>\n\n\n\n<li>If the input is a directory and exists, then display the message \u201cDirectory exists\u201d.<\/li>\n\n\n\n<li>If the input is a regular file, then display the message \u201cIt is a regular file, and the file exists\u201d and display the contents of the file.<\/li>\n\n\n\n<li>If the given input name in step-1 doesn\u2019t exist, then create the new file with the given name in step-1.<br>(Extra credit: 10 points) Add your name to the file (using redirection operator \u2018&gt;\u2019) and display the contents for the newly created file.<\/li>\n\n\n\n<li>Save and exit the editor and remember to make the script executable using the command chmod +x lkopa.sh)<\/li>\n<\/ol>\n\n\n\n<p><\/p>\n\n\n\n<p>Extra Credit(15 points)- Check Directory Write a script like below that<\/p>\n\n\n\n<ol>\n<li>Reads Two variables- your name and the name of the directory as input.<\/li>\n\n\n\n<li>Your script should check for the validity of the given directory name, if the entered filename is a directory, then display its contents<\/li>\n\n\n\n<li>If the directory doesn\u2019t exist, then print an error message \u201cSorry, the entered directory name is not a valid directory name.\u201d<\/li>\n\n\n\n<li>You need to execute your script and test the following directories to test with your script<\/li>\n<\/ol>\n\n\n\n<ul>\n<li>\/etc\/systemd<\/li>\n\n\n\n<li>\/home<\/li>\n\n\n\n<li>A directory that does not exist<br>Display the contents for the directories you have entered<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Step-1: Use vi or nano editor to write your script (Ex, nano lkopa.sh) for the following tasks.Step-2: After saving the script, save and exit out of the editor and make the script executable by adding execute permission ( chmod +x lkopa.sh)Step-3: Run your script using .\/lkopa.sh Task A (Correct script (25 points) + result\/output after [&hellip;]<\/p>\n","protected":false},"author":27037,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","wds_primary_category":0},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/sites.wp.odu.edu\/odu-student-template\/wp-json\/wp\/v2\/posts\/445"}],"collection":[{"href":"https:\/\/sites.wp.odu.edu\/odu-student-template\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sites.wp.odu.edu\/odu-student-template\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sites.wp.odu.edu\/odu-student-template\/wp-json\/wp\/v2\/users\/27037"}],"replies":[{"embeddable":true,"href":"https:\/\/sites.wp.odu.edu\/odu-student-template\/wp-json\/wp\/v2\/comments?post=445"}],"version-history":[{"count":2,"href":"https:\/\/sites.wp.odu.edu\/odu-student-template\/wp-json\/wp\/v2\/posts\/445\/revisions"}],"predecessor-version":[{"id":491,"href":"https:\/\/sites.wp.odu.edu\/odu-student-template\/wp-json\/wp\/v2\/posts\/445\/revisions\/491"}],"wp:attachment":[{"href":"https:\/\/sites.wp.odu.edu\/odu-student-template\/wp-json\/wp\/v2\/media?parent=445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sites.wp.odu.edu\/odu-student-template\/wp-json\/wp\/v2\/categories?post=445"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sites.wp.odu.edu\/odu-student-template\/wp-json\/wp\/v2\/tags?post=445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}