{"id":349,"date":"2025-11-24T15:23:59","date_gmt":"2025-11-24T15:23:59","guid":{"rendered":"https:\/\/sites.wp.odu.edu\/zsumu001\/?p=349"},"modified":"2025-11-30T12:11:51","modified_gmt":"2025-11-30T12:11:51","slug":"assignment-8-shell-script","status":"publish","type":"post","link":"https:\/\/sites.wp.odu.edu\/zsumu001\/2025\/11\/24\/assignment-8-shell-script\/","title":{"rendered":"Assignment 8 &#8211; Shell Script"},"content":{"rendered":"\n<p>Task A (Correct script (25 points) + result\/output after executing the script (25 points)-<br>Conditional Statement<br>Write a shell script using nano or vi editor (eg, vi scriptname.sh) like below, that performs<br>the following task:<br>1. Add the Shebang (#!\/bin\/bash) as the first line in your script.<br>2. Read a number using read function<br>3. Using if statement, check if the input number is greater than 10, then print the message<br>\u201cInput number is greater than 10\u201d.<br>4. If the number is not greater than 10, then print the message, \u201cInput number is not<br>greater than 10\u201d.<\/p>\n\n\n\n<p>Task B (Correct script (25 points) + result\/output after executing the script (25 points) &#8211;<br>Shell Script to Create a new file<br>Write a shell script using nano or vi editor (eg, nano scriptname.sh) like below, that<br>performs the following task:<br>1. Add the Shebang (#!\/bin\/bash) as the first line in your script.<br>2. Reads the name of the file to check for a filename that exists.<br>3. Check whether the given input is a directory or regular file.<br>4. If the input is a directory and exists, then display the message \u201cDirectory exists\u201d.<br>5. If the input is a regular file, then display the message \u201cIt is a regular file, and the file<br>exists\u201d and display the contents of the file.<br>6. If the given input name in step-1 doesn\u2019t exist, then create the new file with the given<br>name in step-1.<\/p>\n\n\n\n<p>(Extra credit: 10 points) Add your name to the file (using redirection operator \u2018&gt;\u2019) and<br>display the contents for the newly created file.<br>7. Save and exit the editor and remember to make the script executable using the<br>command chmod +x scriptname.sh)<\/p>\n\n\n\n<p>Reflection<br>This assignment gave me hands-on experience writing shell scripts reading user input and checking file types in Linux. I found it helpful to reinforce how scripts interact with the file system.<\/p>\n\n\n\n<div data-wp-interactive=\"\" class=\"wp-block-file\"><object data-wp-bind--hidden=\"!selectors.core.file.hasPdfPreview\" hidden class=\"wp-block-file__embed\" data=\"https:\/\/sites.wp.odu.edu\/zsumu001\/wp-content\/uploads\/sites\/31974\/2025\/11\/CYSE270-ASSIGNMENT8.pdf\" type=\"application\/pdf\" style=\"width:100%;height:600px\" aria-label=\"Embed of CYSE270-ASSIGNMENT8.\"><\/object><a id=\"wp-block-file--media-74519d81-9fb6-415d-b0dd-7ea79cf76cce\" href=\"https:\/\/sites.wp.odu.edu\/zsumu001\/wp-content\/uploads\/sites\/31974\/2025\/11\/CYSE270-ASSIGNMENT8.pdf\">CYSE270-ASSIGNMENT8<\/a><a href=\"https:\/\/sites.wp.odu.edu\/zsumu001\/wp-content\/uploads\/sites\/31974\/2025\/11\/CYSE270-ASSIGNMENT8.pdf\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-74519d81-9fb6-415d-b0dd-7ea79cf76cce\">Download<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Task A (Correct script (25 points) + result\/output after executing the script (25 points)-Conditional StatementWrite a shell script using nano or vi editor (eg, vi scriptname.sh) like below, that performsthe <a class=\"more-link\" href=\"https:\/\/sites.wp.odu.edu\/zsumu001\/2025\/11\/24\/assignment-8-shell-script\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":25872,"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\/zsumu001\/wp-json\/wp\/v2\/posts\/349"}],"collection":[{"href":"https:\/\/sites.wp.odu.edu\/zsumu001\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sites.wp.odu.edu\/zsumu001\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sites.wp.odu.edu\/zsumu001\/wp-json\/wp\/v2\/users\/25872"}],"replies":[{"embeddable":true,"href":"https:\/\/sites.wp.odu.edu\/zsumu001\/wp-json\/wp\/v2\/comments?post=349"}],"version-history":[{"count":5,"href":"https:\/\/sites.wp.odu.edu\/zsumu001\/wp-json\/wp\/v2\/posts\/349\/revisions"}],"predecessor-version":[{"id":513,"href":"https:\/\/sites.wp.odu.edu\/zsumu001\/wp-json\/wp\/v2\/posts\/349\/revisions\/513"}],"wp:attachment":[{"href":"https:\/\/sites.wp.odu.edu\/zsumu001\/wp-json\/wp\/v2\/media?parent=349"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sites.wp.odu.edu\/zsumu001\/wp-json\/wp\/v2\/categories?post=349"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sites.wp.odu.edu\/zsumu001\/wp-json\/wp\/v2\/tags?post=349"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}