Document Details

Uploaded by Deleted User

OCR

Tags

Bash scripting programming computer science

Summary

This document contains multiple-choice questions on Bash scripting concepts. The questions cover various aspects of Bash scripting, including conditional statements, loops, and common commands, and are perfect for preparing for an upcoming Bash exam.

Full Transcript

Pre-Exam III What does case $answer in indicate? (A) Starts a loop for variable evaluation (B) Declares a function parameter (C) Begins a conditional block based on the value of answer (D) Maps input to...

Pre-Exam III What does case $answer in indicate? (A) Starts a loop for variable evaluation (B) Declares a function parameter (C) Begins a conditional block based on the value of answer (D) Maps input to a predefined value What does case $answer in indicate? (A) Starts a loop for variable evaluation (B) Declares a function parameter (C) Begins a conditional block based on the value of answer (D) Maps input to a predefined value What does the exit 0 (A) Terminates the current function (B) Resets the program flow (C) Restarts the program (D) Exits the script successfully What does the exit 0 (A) Terminates the current function (B) Resets the program flow (C) Restarts the program (D) Exits the script successfully What does -ne in echo (A) Starts a loop for variable evaluation (B) Declares a function parameter (C) Newline disabled (D) Do not automatically append a newline What does -ne in echo (A) Starts a loop for variable evaluation (B) Declares a function parameter (C) Newline disabled (D) Do not automatically append a newline What is the purpose of read -r answer? (A) Allows escape characters in input (B) Prevents backslash escape interpretation (C) Reads multiple lines of input (D) Reads input without spaces What is the purpose of read -r answer? (A) Allows escape characters in input (B) Prevents backslash escape interpretation (C) Reads multiple lines of input (D) Reads input without spaces If 1 is chosen in the main menu, what happens? (A) Exits the script (B) Returns to the main menu (C) Calls the submenu function (D) Displays "Wrong option." If 1 is chosen in the main menu, what happens? (A) Exits the script (B) Returns to the main menu (C) Calls the submenu function (D) Displays "Wrong option." What function does 3 (A) Exits the script (B) Returns to submenu (C) Returns to mainmenu What function does 3 (A) Exits the script (B) Returns to submenu (C) Returns to mainmenu How does the program handle invalid options in submenu? (A) Displays "Wrong option." and exits with code 1 (B) Loops back to submenu (C) Returns to the main menu (D) Exits silently How does the program handle invalid options in submenu? (A) Displays "Wrong option." and exits with code 1 (B) Loops back to submenu (C) Returns to the main menu (D) Exits silently What is the purpose of the submenu function? (A) Terminates the program (B) Provides additional menu options (C) Redirects output (D) Handles invalid inputs What is the purpose of the submenu function? (A) Terminates the program (B) Provides additional menu options (C) Redirects output (D) Handles invalid inputs What does the Kosove function do? (A) Simulates opening a URL and exits successfully (B) Redirects to the submenu (C) Displays a warning message (D) Restarts the script What does the Kosove function do? (A) Simulates opening a URL and exits successfully (B) Redirects to the submenu (C) Displays a warning message (D) Restarts the script How is user input validated in the script? (A) Through if statements (B) Using regular expressions (C) Via case constructs (D) Through the read command alone How is user input validated in the script? (A) Through if statements (B) Using regular expressions (C) Via case constructs (D) Through the read command alone What is the purpose of the while true; do... done construct? (A) Executes commands in sequence once (B) Runs the menu a fixed number of times (C) Creates an infinite loop for the menu (D) Terminates the script What is the purpose of the while true; do... done construct? (A) Executes commands in sequence once (B) Runs the menu a fixed number of times (C) Creates an infinite loop for the menu (D) Terminates the script Which function is called when the user selects 1? (A) list_files (B) create_directory (C) create_file( D) Exits the menu Which function is called when the user selects 1? (A) list_files (B) create_directory (C) create_file( D) Exits the menu What does the script do if the user selects 2? (A) Calls the create_file function (B) Deletes all files (C) Calls the list_files function (D) Restarts the menu What does the script do if the user selects 2? (A) Calls the create_file function (B) Deletes all files (C) Calls the list_files function (D) Restarts the menu What does the -p flag in mkdir -p do? (A) Deletes existing directories (B) Creates parent directories if they don't exist (C) Displays an error if the directory exists (D) Makes the directory private What does the -p flag in mkdir -p do? (A) Deletes existing directories (B) Creates parent directories if they don't exist (C) Displays an error if the directory exists (D) Makes the directory private What does the create_file function accomplish? (A) Deletes a file (B) Copies a file (C) Creates an empty file with the given name (D) Lists all files What does the create_file function accomplish? (A) Deletes a file (B) Copies a file (C) Creates an empty file with the given name (D) Lists all files What does the -l flag in the ls command do in list_files? (A) Displays hidden files (B) Shows files in long format with details (C) Sorts files alphabetically (D) Deletes empty files What does the -l flag in the ls command do in list_files? (A) Displays hidden files (B) Shows files in long format with details (C) Sorts files alphabetically (D) Deletes empty files What does ls -l "$directory" do if $directory does not exist? (A) Creates the directory automatically (B) Displays error the directory does not exist (C) Loops back to the menu() D) Exits the program What does ls -l "$directory" do if $directory does not exist? (A) Creates the directory automatically (B) Displays error the directory does not exist (C) Loops back to the menu( D) Exits the program How can the script ensure that dirname is not empty in create_directory? (A) Add a default name if dirname is empty (B) Use an if statement to check the value of dirname (C) Force the user to restart the program (D) Allow empty names by default How can the script ensure that dirname is not empty in create_directory? (A) Add a default name if dirname is empty (B) Use an if statement to check the value of dirname (C) Force the user to restart the program (D) Allow empty names by default What is the purpose of the seating function? (A) Displays the seating chart and ticket prices for movies (B) Books tickets for a specific seat (C) Displays the movie schedule (D) Processes payment for tickets What is the purpose of the seating function? (A) Displays the seating chart and ticket prices for movies (B) Books tickets for a specific seat (C) Displays the movie schedule (D) Processes payment for tickets How are movie prices structured in the seating function? (A) All movies have the same price (B) Regular and VIP seats have different prices for each movie (C) Prices are determined by seat availability (D) Prices are dynamic based on demand How are movie prices structured in the seating function? (A) All movies have the same price (B) Regular and VIP seats have different prices for each movie (C) Prices are determined by seat availability (D) Prices are dynamic based on demand How is the total cost of the tickets calculated? (A) Using a predefined function (B) By multiplying the price by the number of tickets (C) Based on a fixed cost (D) By adding the price and tickets values How is the total cost of the tickets calculated? (A) Using a predefined function (B) By multiplying the price by the number of tickets (C) Based on a fixed cost (D) By adding the price and tickets values What command is used to prompt the user for input in Bash? (A) echo (B) read (C) input (D) prompt What command is used to prompt the user for input in Bash? (A) echo (B) read (C) input (D) prompt How does read -s differ from read -p? (A) Prompts the user for a secret code (B) Suppresses the input from being displayed on the screen (C) Forces numeric input only (D) Reads input silently into a file How does read -s differ from read -p? (A) Prompts the user for a secret code (B) Suppresses the input from being displayed on the screen (C) Forces numeric input only (D) Reads input silently into a file Question ?

Use Quizgecko on...
Browser
Browser