Shell Scripting Quiz (Set 13) Shell Scripting (Set 3) 1 / 10 What is the purpose of the 'expr' command in a shell script? Displays environment variables Evaluates expressions Counts the number of lines in a file Searches for text patterns 2 / 10 Which operator is used for logical AND in a shell script? || ! & && 3 / 10 What is the purpose of the 'case' statement in a shell script? Performs pattern-based branching Creates a loop Defines a function Executes external commands 4 / 10 In a shell script, how do you check if a file exists? if [ -e file.txt ]; then if (file.txt exists); then if [ file.txt ]; then if {file.txt}; then 5 / 10 Which command is used to remove a directory and its contents in a shell script? rmdir rm -r cleandir removedir 6 / 10 What is the purpose of the 'test' command in a shell script? Runs unit tests Compiles source code Evaluates conditional expressions Performs text transformations 7 / 10 Which special variable represents the script's filename in a shell script? $filename $script $0 $name 8 / 10 What is the purpose of the 'basename' command in a shell script? Extracts the filename from a path Prints the working directory Displays the content of a file Searches for files 9 / 10 Which command is used to make a new directory and any necessary parent directories? makedir mkdir -p newdir createdir 10 / 10 What is the purpose of the 'for' loop in a shell script? Performs conditional branching Iterates over a sequence of values Executes a block of code a specific number of times Reads user input Your score isThe average score is 0% 0% Restart quiz