Shell Scripting Quiz (Set 4) Shell Scripting (Set 4) 1 / 10 In a shell script, how do you check if a directory exists? if {directory}; then if (directory exists); then if [ -d directory ]; then if [ directory ]; then 2 / 10 What is the purpose of the 'shift' command in a shell script? Moves a file to another location Shifts the positional parameters to the left Increments a variable's value Pauses script execution 3 / 10 Which operator is used for logical OR in a shell script || && ! | 4 / 10 What is the purpose of the 'getopts' command in a shell script? Parses command line options and arguments Gets user input Fetches remote files Prints system information 5 / 10 In a shell script, how do you compare two strings for equality? [ str1 == str2 ] [ $str1 = $str2 ] [ $str1 == $str2 ] [ str1 = str2 ] 6 / 10 What is the purpose of the 'cut' command in a shell script? Extracts specific columns from text Deletes lines from a file Copies files and directories Finds and replaces text 7 / 10 Which variable is used to access the arguments passed to a shell script? $args $@ $arguments $params 8 / 10 What is the purpose of the 'dirname' command in a shell script? Displays the current working directory Deletes a directory Extracts the directory from a path Renames a file 9 / 10 In a shell script, how do you append text to a file? append 'text' file.txt write 'text' file.txt add 'text' to file.txt echo 'text' >> file.txt 10 / 10 What is the purpose of the 'unset' command in a shell script? Deletes a file Removes the value of a variable Closes the current shell session Kills a running process Your score isThe average score is 0% 0% Restart quiz