A system administrator is creating a shell script that will automate the configuration of a new service on a Linux server. The script needs to append a multi-line configuration block to a file named /etc/service.conf. The administrator decides to use a here document within the script to achieve this. Which of the following snippets will correctly append the configuration block to the end of the file using a here document?
A here document allows the input of multi-line text strings in shell scripts. It starts with the << operator followed by a delimiter that indicates the end of the here document. The correct answer provides the correct syntax with <<EOF as the starting delimiter and EOF on a line by itself to signify the end. The >> operator is used to append to /etc/service.conf file without overwriting its current contents. The incorrect answers either use wrong syntax, which will not work as expected, or will not append the text correctly.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is a here document in shell scripting?
Open an interactive chat with Bash
What is the difference between `>` and `>>` in shell scripting?
Open an interactive chat with Bash
When would I use a here document instead of multiple echo commands?