Changes

Jump to: navigation, search

Tutorial 12 - Shell Scripting - Part 2

3,120 bytes added, 14:15, 14 November 2021
LINUX PRACTICE QUESTIONS
= LINUX PRACTICE QUESTIONS =
The purpose of this section is to obtain '''extra practice''' to help with '''quizzes''', your '''midterm''', and your '''final exam'''.
 
Here is a link to the [ MS Word Document of ALL of the questions https://matrix.senecacollege.ca/~osl640/questions/osl640_week12_practice.docx ] displayed below but with extra room to answer on the document to
simulate a quiz:
 
Your instructor may take-up these questions during class. It is up to the student to attend classes in order to obtain the answers to the following questions. Your instructor will NOT provide these answers in any other form (eg. e-mail, etc).
 
 
'''Review Questions:'''
 
# Write code for a Bash shell script that clears the screen, and then prompts the user for their age. If the age entered is less than 65, then display a message that the person is NOT eligible to retire. If the age is equal to 65, then display a message that the person just turned 65 and can retire. If the age is greater than 65, then display the message that the user is over 65 and why have they not have already retired already?<br><br>
# Add code to the script created in the <u>previous</u> question to force the user to enter only an '''integer''' to provide error-checking for this shell script.<br><br>
#Write code for a Bash shell script that will prompt the user for a '''valid POSTAL CODE'''.<br>A valid postal code consists of the following format: '''x#x #x#'''<br>where '''x''' represents an upper or lowercase letter<br>and '''#''' represents a number from 0-9<br><br>Also VALID postal codes can consist of no spaces or one or more spaces in the format shown above.<br><br>If the user enters an '''INVALID postal code''', indicate an error and allow the user to enter the VALID postal code. When the user enters a VALID postal code, then clear the screen and display the VALID postal code.<br><br>
# Write code that works similar to the previous question, but have it read an input file called '''unchecked-postalcodes.txt''' and only save VALID postal codes to a file called:<br>'''valid-postalcodes.txt'''<br><br>Design your Bash Shell script to only run if the user enters TWO ARGUMENTS:<br>'''unchecked-postalcodes.txt''' and '''valid-postalcodes.txt'''<br><br>Otherwise, display an error message and immediately exit your Bash Shell script with a false exit value.<br><br>
# What is the purpose of the '''/etc/profile''' startup file?<br><br>
# What is the purpose of the '''/etc/bashrc''' startup file?<br><br>
# What is the purpose of the '''~/.bashrc''' startup file?<br><br>
# What is the purpose of the '''~/.bash_profile''' file?<br><br>
# What is the purpose of the '''~/.bash_logout''' file?<br><br>
# Write <u>code</u> for the '''~/.bash_profile''' file below to clear the screen, welcome the user by their username, and display a list of all users currently logged into your Matrix server. Insert blank lines between each of those elements.<br><br>
# Write a command to <u>run</u> the recently created '''~/.bash_profile''' startup file from the previous question without exiting and re-logging into your Matrix account.<br><br>
 
 
 
[[Category:OSL640]]

Navigation menu