Writing simple shell scripts
Lesson 2 of 2 in objective 105. Shells and shell scripting, part of LPIC-1 Exam 102-500.
- Objective
- 105. Shells and shell scripting
- Share of the exam
- 15% (the whole objective)
- Questions in this lesson
- 11
- Signed for by a person
- 0
Partly checked. None of the 11 questions here has been read against the cited source by a person. 11 questions have been checked against their cited clause by an automated pass — which is not the same thing, and is not a signature.
Only questions a person has signed for are used in mock exams here. That is the whole difference between the two kinds of checking above.
Questions in this lesson
- A command finishes and the shell reports an exit status of 0. What does that mean, and which parameter reports it? machine-checked
- Which statement correctly distinguishes bash's `[[ ... ]]` from `[ ... ]`? machine-checked
- Inside a shell script, which special parameter expands to the number of positional parameters the script was given? machine-checked
- A script contains the line `mkdir /srv/data && cp report.txt /srv/data/`. Under what condition does the cp run? machine-checked
- Which keyword closes a `case` construct in a bash script? machine-checked
- A script is called with two arguments: `./run.sh "annual report" 2026`. How does `"$@"` differ from `"$*"` when the script passes them on to another command? machine-checked
- Which three loop headers cause a bash script to iterate exactly over the numbers 1 to 5? Assume default bash options and an empty current directory. (Choose three.) machine-checked
- Type the first line a script must contain so that the kernel runs it with the Bourne Again shell installed at /bin/bash. machine-checked
- Type the special parameter, including its leading dollar sign, that expands to the exit status of the most recently completed foreground command. machine-checked
- Using symbolic mode and changing no other permission bits, type the command that adds the execute permission for all three permission classes (user, group and other) to the file backup.sh in the current directory. machine-checked
- Type the bash builtin command, with its argument, that reads one line from standard input and stores it in the shell variable named ANSWER. machine-checked
Drill this lesson
A lesson is one sitting: the trainer draws a short run from these questions alone and spaces the ones you get wrong.
Practise Writing simple shell scripts
The rest of objective 105
- Customizing the shell environment
- Writing simple shell scripts — you are here