1. To run a copy command in a subshell, which syntax would you use?
2. Using "awk", what would the output of this command string be? echo "1 2 3" | awk '{for (i=1; i<=NF; i++) s=s+$i};END {print s}'
3. The command below will search the root filesystem for files named "finance.db". In this context, what information is being sent to /dev/null? find / -name "finance.db" 1>results.txt 2>/dev/null
4. To permanently remove empty lines from a file called textfile, which command could you use?
5. Assuming that user1 existed, what would be the result of this command string? awk -F: '/user1/{print $1 "-" $3 "-" $6}' /etc/passwd
6. What happens if you use the "set -e" in a Bash script?
7. The _ keyword pauses the script to get input from standard input.
8. If file.sql holds SQL statements to be executed, what will be in file.txt? mysql < file.sql > file.txt
9. How does the SUID or setuid affect executable commands?
10. In order to extract text from the first column of file called textfile, which command would you use?
11. What is the keyboard shortcut to call up the Bash history search as shown below? (reverse-i-search)`':
12. Which arithmetic expression will give the most precise answer?
13. What is the result of this script? txt=Penguins [[ $txt =~ [a-z]{8} ]]; echo $?
14. How would you change your Bash shell prompt to the following? HAL>
15. What is the output of this code? VAR="/var/www/html/website.com/html/"; echo "${VAR#*/html}"
16. If prompted for text at the standard input, you can tell the command you're done entering text with what key combination?
17. In order for a Bash script to be executed like an OS command, it should start with a shebang line. What does this look like?
18. What line of Bash script probably produced the output shown below? The date is: Sun Mar 24 12:30:06 CST 2019!
19. Suppose your current working directory is your home directory. How could you run the script demo.sh that is located in your home directory? Find three correct answers. A. /home/demo.sh B. ./demo.sh C. ~/demo.sh D. bash /home/demo.sh E. bash demo.sh
20. How could you get a list of all .html files in your tree?
21. What would be in out.txt? cat < in.txt > out.txt
22. What does this bash statement do? (( $a == $b ); echo $?
23. What do you use in a case statement to tell Bash that you're done with a specific test?
24. What Bash script will correctly create these files?
25. Which variable would you check to verify that the last command executed successfully?
26. How can you gather history together for multiple terminals?
27. What is the difference between the $@ and $* variables?
28. Which file allows you to save modifications to the shell environment across sessions?
29. What file would match the code below? ls Hello[[.vertical-line.]]World
30. What will be in out.txt? ls nonexistentfile | grep "No such file" > out.txt
31. What will be the difference between the output on the screen and the contents of out.txt mysql < file.sql > out.txt
32. How would you find the last copy command run in your history?
33. In order to write a script that iterates through the files in a directory, which of the following could you use?
34. When executing a command and passing the output of that command to another command, which character allows you to chain these commands together?
35. Which statement checks whether the variable num is greater than five?
36. When used from within a script, which variable contains the name of the script?
37. What does the + signify at the end of the 10-digit file permissions on data.txt? ls -l -rwx------+ 1 user1 u1 0 Oct 1 10:00 data.txt
38. In Bash, what does the comment below do? cd -
39. What does this command do? cat > notes -
40. What is the output of: VAR="This old man came rolling" echo "\${VAR//man/rolling}"
41. The shell looks at the contents of a particular variable to identify which programs it can run. What is the name of this variable?
42. What does this command sequence do? cat >notes -
43. What is the output of this code? VAR="This old man came rolling" echo "${VAR//man/rolling}"
44. What statement would you use to print this in the console? Shall we play a game? yes\no
45. Which one is true?
46. Which does the below command do? w
47. Which sed options should you use to change the second-to-last instance of variable to rock so it would read: A constant is a variable that is a rock that isn't variable var="A constant is a variable that is a variable that isn't variable" echo "$var" | sed _____
48. To make a Bash script named script.sh executable, what should you run?
49. How can you create a shared terminal in a Bash shell?
50. Wich operator sends the output of ls to a file for later use?
51. When comparing items with case, what statement indicates an end to the evaluation block?
52. To run a group of commands without spawning a subshell, which syntax would you use?
53. What are the results of the command with a user named jon? echo 'Hello, $(whoami)!'
54. How can you copy a directory to another system with compression?
55. To assign the command ls -lah to the shortcut command lh, what command should you use?
56. Which statement will print all of the fully qualified .cvs files in the home directory or subdirectories while not displaying any errors?
57. In Bash, what does a # at the end of the default prompt string indicate?
58. Which variable contains the process ID (PID) of the script while it's running?