Curated

Automation, Orchestration, and Scripting

0 votes

Questions113

  1. Question 1

    Automation, Orchestration, and Scripting

    A single playbook must install httpd on RHEL-family hosts and apache2 on Debian-family hosts. Which Ansible component supplies the OS family value used in the when condition?

    Show the answer

    Correct answerC. Facts gathered by the setup module

    The setup module gathers facts such as ansible_facts['os_family'], which a when condition can test at runtime. Inventory group names only work if an admin grouped hosts by OS manually; they are not discovered from the system.

    Open this question
  2. Question 2

    Automation, Orchestration, and Scripting

    A task updates /etc/nginx/nginx.conf from a template. Nginx must reload only if the file actually changed, and only once even when several tasks change its configuration. Which component provides this behavior?

    Show the answer

    Correct answerA. A handler triggered with notify

    A task that reports changed notifies a handler, which runs once at the end of the play regardless of how many tasks notified it. Tags only select which tasks run and have no change-detection logic.

    Open this question
  3. Question 3

    Automation, Orchestration, and Scripting

    A playbook must run its tasks only on the hosts listed under the [dbservers] group in the inventory. Which play-level keyword selects those hosts?

    Show the answer

    Correct answerA. hosts: dbservers

    The hosts keyword maps a play to hosts or groups defined in the inventory. The become keyword controls privilege escalation, not which machines are targeted, so it cannot select a group.

    Open this question
  4. Question 4

    Automation, Orchestration, and Scripting

    A new Linux server has only SSH access and a standard Python installation. Which statement describes what Ansible needs on this managed node to run a playbook against it?

    Show the answer

    Correct answerC. No Ansible package; SSH access and Python are sufficient

    Ansible is agentless: the control node connects over SSH and runs modules using the node's Python interpreter. The ansible-core package is needed only on the control node, not on managed nodes.

    Open this question
  5. Question 5

    Automation, Orchestration, and Scripting

    A playbook needs the ansible.posix.firewalld module, which is not included in the installed ansible-core. What is the correct way to make it available?

    Show the answer

    Correct answerC. Install the ansible.posix collection on the control node

    Collections distribute modules, plugins and roles, and are installed on the control node with ansible-galaxy collection install. Managed nodes need no extra packages because modules are copied over SSH when a task runs.

    Open this question
  6. Question 6

    Automation, Orchestration, and Scripting

    A new web server has the Puppet agent installed and runs puppet agent -t for the first time. The run reports that no signed certificate is available, and no catalog is applied. What should the administrator do on the Puppet server?

    Show the answer

    Correct answerA. Sign the pending certificate request from the node

    The agent submits a certificate signing request to the Puppet CA, and the server only compiles a catalog for it after the request is signed (for example with puppetserver ca sign). Adding the node to site.pp is classification and does not satisfy the trust requirement.

    Open this question
  7. Question 7

    Automation, Orchestration, and Scripting

    An administrator creates a Puppet module named ntp. The main class, also named ntp, must load when a manifest contains the statement include ntp. In which location should the class be defined?

    Show the answer

    Correct answerD. ntp/manifests/init.pp

    A module's manifests directory holds its classes, and init.pp must define the class that shares the module's name. The files directory is tempting but only serves static files for file resources, not Puppet code.

    Open this question
  8. Question 8

    Automation, Orchestration, and Scripting

    A team wants nodes to stay in their desired state without anyone logging in to them. Which description matches how a standard Puppet deployment does this?

    Show the answer

    Correct answerD. The agent requests a catalog from the server and applies it, at intervals.

    Puppet is agent-based and pull-driven: the agent checks in with the server over TLS (every 30 minutes by default), receives a catalog and enforces it locally. Remote SSH execution describes agentless tools such as Ansible, not standard Puppet.

    Open this question
  9. Question 9

    Automation, Orchestration, and Scripting

    A developer wrote a class named webserver, but none of its resources appear on a node after several agent runs. Which two actions cause the class to be applied to that node? (Choose two.)

    Choose 2 answers

    Show the answer

    Correct answersB. Assign the class to the node through an external node classifierC. Declare the class with include in the node's definition in site.pp

    A class is only applied once it is declared or assigned to a node, either with include in the node's manifest or through classification such as an ENC. Running Facter only reports facts and does not classify the node.

    Open this question
  10. Question 10

    Automation, Orchestration, and Scripting

    A manifest must install the apache2 package on Debian nodes and the httpd package on RHEL nodes, choosing between them by the node's OS family. Which Puppet component supplies the OS family value when the catalog is compiled?

    Show the answer

    Correct answerD. Facter

    Facter runs on the agent, collects system facts such as the OS family, and sends them to the server for catalog compilation. PuppetDB is tempting, but it only stores facts and catalogs after the fact and does not collect them.

    Open this question
  11. Question 11

    Automation, Orchestration, and Scripting

    An administrator accidentally deletes the local state file for a configuration that was already applied. The virtual machines it created are still running. The administrator then runs tofu apply with the unchanged configuration. What is the most likely result?

    Show the answer

    Correct answerA. It plans to create every resource again, since none are recorded

    State is how OpenTofu maps configuration to real objects. With no state, it treats every resource as new and plans to create it again. It does not discover existing objects through the API; that requires tofu import.

    Open this question
  12. Question 12

    Automation, Orchestration, and Scripting

    A junior administrator clones a repository containing OpenTofu configuration files for a cloud platform and runs tofu init in the working directory. Which two actions does this command perform? (Choose two.)

    Choose 2 answers

    Show the answer

    Correct answersB. Downloads the provider plugins the configuration requiresC. Initializes the configured backend that stores state

    tofu init installs the required provider plugins and sets up the backend where state is kept. Previewing changes is the job of tofu plan, and creating resources is done by tofu apply, so neither happens at init.

    Open this question
  13. Question 13

    Automation, Orchestration, and Scripting

    In OpenTofu, what is a provider?

    Show the answer

    Correct answerA. A plugin that translates resource declarations into API calls to a target platform

    AWhy this is right: A provider plugin holds the API logic that turns resource blocks into create, read, update and delete calls.

    BWhy not this: The record of managed resources is the state file, not a provider.

    CWhy not this: A reusable group of resources is a module.

    DWhy not this: A remote place that stores and locks state is a backend.

    Providers are plugins that hold the logic for authenticating to a platform and calling its API to create, read, update and delete resources. OpenTofu core itself does not know any platform's API.

    Open this question
  14. Question 14

    Automation, Orchestration, and Scripting

    A colleague changes the size of a managed server directly in the cloud console. The configuration and state file still show the original size. The administrator then runs tofu plan. What does OpenTofu do?

    Show the answer

    Correct answerA. It queries the provider API, detects drift and proposes a fix

    Plan refreshes its view of real infrastructure through the provider API, notices the difference from the configuration, and proposes a change to restore the declared size. It does not blindly trust state, and it never edits configuration files.

    Open this question
  15. Question 15

    Automation, Orchestration, and Scripting

    A team's pipeline sometimes installs a newer release of a cloud provider plugin than the one used during testing, causing unexpected plan differences. Where should the team set the allowed provider version so that tofu init selects a consistent release?

    Show the answer

    Correct answerA. A required_providers block with a version constraint

    The required_providers block declares each provider's source and version constraint, which tofu init uses when choosing a plugin. Variable defaults and outputs do not control plugin selection, and lifecycle arguments affect resource behavior only.

    Open this question
  16. Question 16

    Automation, Orchestration, and Scripting

    An administrator launches a cloud instance and supplies a user-data file whose first line is #cloud-config. The YAML creates a user, installs a package and sets the timezone during first boot. Which tool processes this file?

    Show the answer

    Correct answerC. cloud-init

    The #cloud-config header identifies a cloud-init configuration, which cloud-init processes at first boot to create users, install packages and set the timezone. Kickstart uses a different syntax and is read by the installer, not by a booted instance.

    Open this question
  17. Question 17

    Automation, Orchestration, and Scripting

    An administrator must install Rocky Linux on 40 bare-metal servers that boot over PXE. Every server needs the same disk layout, package group and root password defined in one text file, with no prompts during installation. Which tool BEST meets this requirement?

    Show the answer

    Correct answerC. Kickstart

    Kickstart is the answer file for RHEL-family installers and supplies partitioning, packages and accounts so the install runs unattended. cloud-init configures an already installed instance at first boot and does not drive the OS installer or partition during installation.

    Open this question
  18. Question 18

    Automation, Orchestration, and Scripting

    A team builds one Linux image that is launched on several cloud providers. Each instance must set its own hostname, add an SSH key and run a setup script on first boot, using data supplied by the provider's metadata service. Which tool should be built into the image?

    Show the answer

    Correct answerC. cloud-init

    cloud-init reads provider metadata and user data on first boot and applies hostname, SSH key and script settings. Kickstart only automates the installer, so it plays no part when an instance starts from an existing image.

    Open this question
  19. Question 19

    Automation, Orchestration, and Scripting

    A team must automate two tasks. First, install Rocky Linux from an ISO onto bare-metal servers without any prompts. Second, configure cloud VMs launched from a base image by using user data at first boot. Which two tools fit these tasks? (Choose two.)

    Choose 2 answers

    Show the answer

    Correct answersB. cloud-initC. Kickstart

    Kickstart answers the installer's questions for unattended RHEL-family installs, and cloud-init applies user data to cloud instances at first boot. Terraform provisions infrastructure but does not answer installer prompts or process user data on the instance itself.

    Open this question
  20. Question 20

    Automation, Orchestration, and Scripting

    A technician boots a Rocky Linux installation ISO and adds the inst.ks=http://repo.example.com/ks.cfg option to the boot line. Which component reads the file and carries out the installation without prompting?

    Show the answer

    Correct answerC. Anaconda

    Anaconda is the RHEL-family installer and is the component that interprets a Kickstart file passed with inst.ks. dracut only builds the initramfs and cloud-init runs on an installed system after the installer has finished.

    Open this question
  21. Question 21

    Automation, Orchestration, and Scripting

    Administrators regularly change settings on production Linux hosts by hand, and the running configuration has drifted from what the team believes is deployed. The team wants a GitOps approach to fix this. Which action BEST fits?

    Show the answer

    Correct answerA. Declare the desired state in a Git repository and have an agent reconcile hosts to it

    GitOps treats a Git repository as the source of truth for desired state, and an automated agent applies and reconciles it, with changes made through reviewed commits. Nightly backups and wiki notes only record drift after it occurs and do not enforce the declared state.

    Open this question
  22. Question 22

    Automation, Orchestration, and Scripting

    A team's defects are usually found by QA in the staging environment, days after the code was written, which makes fixes slow and costly. The team wants to apply shift left testing. Which change BEST meets this goal?

    Show the answer

    Correct answerB. Run unit tests and linting automatically on every commit and pull request

    Shift left moves testing earlier in the lifecycle, so automated unit tests and linting on each commit or pull request give developers immediate feedback. Extending staging soak time or adding late manual reviews keeps testing late, which does not shift it left.

    Open this question
  23. Question 23

    Automation, Orchestration, and Scripting

    A security team found that developers sometimes commit vulnerable third-party libraries and hardcoded credentials, which are discovered only after release. The company wants to adopt DevSecOps. Which change BEST addresses this?

    Show the answer

    Correct answerD. Add automated dependency scanning and secret detection stages to the pipeline

    DevSecOps embeds automated security checks in the pipeline so vulnerable dependencies and exposed secrets are caught before merge or release. Periodic penetration tests and manual artifact reviews happen too late and do not scale with each commit.

    Open this question
  24. Question 24

    Automation, Orchestration, and Scripting

    A pipeline builds each merged change, runs the automated tests and deploys it to staging. Policy requires a manager to click an approval button before the same artifact goes to production. Which practice does this pipeline describe?

    Show the answer

    Correct answerA. Continuous delivery

    Continuous delivery keeps every change in a releasable state, with a manual approval gate before production. Continuous deployment is the tempting alternative, but it releases to production automatically with no human approval step.

    Open this question
  25. Question 25

    Automation, Orchestration, and Scripting

    A database pod writes its data to a volume. When the pod is deleted and rescheduled to another node, the data must still be available to the new pod. Which object should the administrator use to request this storage?

    Show the answer

    Correct answerC. A PersistentVolumeClaim

    A PersistentVolumeClaim requests storage from a PersistentVolume, whose lifecycle is independent of any pod, so the data outlives the pod. An emptyDir volume is tempting because it is a volume, but it is created with the pod and deleted when the pod is removed from the node.

    Open this question
  26. Question 26

    Automation, Orchestration, and Scripting

    An administrator must run three identical replicas of a stateless web application. If a pod fails, a replacement must start automatically, and new image versions must roll out gradually without downtime. Which object should the administrator create?

    Show the answer

    Correct answerB. Deployment

    A Deployment manages a ReplicaSet to keep the desired number of pod replicas running and performs rolling updates. A DaemonSet is tempting because it also manages pods, but it runs one pod per node instead of a set replica count and is not for versioned rollouts of a web tier.

    Open this question
  27. Question 27

    Automation, Orchestration, and Scripting

    A front-end application in a cluster cannot reliably reach a back-end application. The back-end pods are replaced regularly, and each new pod receives a different IP address. Which object gives the front end a stable address and name for reaching whichever back-end pods are currently running?

    Show the answer

    Correct answerA. Service

    A Service provides a stable virtual IP and DNS name and load-balances across the pods that match its label selector. An Ingress is tempting, but it routes external HTTP/HTTPS traffic into Services and does not give internal pods a stable address by itself.

    Open this question
  28. Question 28

    Automation, Orchestration, and Scripting

    A team deploys an application to a Kubernetes cluster. The application needs a database password at runtime, and the password must be stored as its own object instead of being written into the pod specification. Which Kubernetes object is intended for this purpose?

    Show the answer

    Correct answerC. Secret

    A Secret holds sensitive data such as passwords and tokens, and pods can consume it as environment variables or mounted files. A ConfigMap is tempting, but it is meant for non-confidential configuration and gives no special handling to sensitive values.

    Open this question
  29. Question 29

    Automation, Orchestration, and Scripting

    An administrator is planning the manager nodes for a new Docker Swarm cluster. Which four statements about Swarm nodes are correct? (Choose four.)

    Choose 4 answers

    Show the answer

    Correct answersA. Manager nodes keep the swarm state consistent by using the Raft consensus algorithm.B. An odd number of manager nodes is recommended so that a quorum majority can always be reached.C. A worker node can be promoted to a manager node with the docker node promote command.E. A manager node can run service tasks unless its availability is set to drain.

    Managers hold Raft state, can run tasks by default, can be promoted from workers, and are best deployed in odd numbers. Workers only run tasks; they do not take part in Raft or accept swarm management commands such as docker service create.

    Open this question
  30. Question 30

    Automation, Orchestration, and Scripting

    A team needs a monitoring agent service that runs exactly one task on every node in the swarm, including nodes that join later, without anyone changing the service afterward. How should the service be created?

    Show the answer

    Correct answerC. With --mode global so that one task runs on every node

    Global mode places one task on every node and automatically adds one when a new node joins. A fixed replica count does not follow cluster growth, and the worker-role constraint would also exclude manager nodes.

    Open this question
  31. Question 31

    Automation, Orchestration, and Scripting

    An administrator deploys two Swarm services on different nodes. The api service must reach the db service by its service name, and the traffic must cross hosts. Which network driver should both services be attached to?

    Show the answer

    Correct answerD. overlay

    An overlay network spans the swarm nodes and provides service-name DNS resolution across hosts. A bridge network is local to a single Docker host, so it cannot carry traffic between containers on different nodes.

    Open this question
  32. Question 32

    Automation, Orchestration, and Scripting

    A Swarm service named web is running with three replicas spread across three worker nodes. One worker loses power and goes offline. Which behavior should the administrator expect?

    Show the answer

    Correct answerC. The manager schedules a replacement task on another available node to restore three running replicas.

    The Swarm orchestrator continuously reconciles actual state with the desired state, so tasks lost with the node are rescheduled on healthy nodes. Swarm does not live-migrate containers or lower the desired replica count; it starts new tasks.

    Open this question
  33. Question 33

    Automation, Orchestration, and Scripting

    An administrator has a docker-compose.yml file in /opt/shop that defines three services. None of the containers have been created yet. The administrator wants to create and start all of them so they keep running after the SSH session is closed. Which command should be run from /opt/shop?

    Show the answer

    Correct answerC. docker compose up -d

    up -d creates the networks and containers, starts every service and returns the prompt by running detached. start only starts containers that already exist, so it does nothing here. Plain up creates them but stays attached to the terminal.

    Open this question
  34. Question 34

    Automation, Orchestration, and Scripting

    A web application started with Compose is returning errors. The administrator wants to watch new log output from only the db service as it is written, from the project directory. Which command does this?

    Show the answer

    Correct answerC. docker compose logs -f db

    logs -f follows the output of the named service and keeps streaming new lines. Without -f, logs prints the existing output once and exits, so new entries are not shown. ps and top show status and processes, not logs.

    Open this question
  35. Question 35

    Automation, Orchestration, and Scripting

    A Compose file defines a db service running PostgreSQL. After each docker compose down followed by docker compose up -d, the database is empty. The administrator wants the data kept in a Docker-managed volume that survives down. Which change to the Compose file achieves this?

    Show the answer

    Correct answerA. Mount a named volume at /var/lib/postgresql/data and declare it under the top-level volumes key

    A named volume mapped to the data directory and declared in the top-level volumes section lives outside the container, so down does not delete it. A restart policy only restarts containers and does not preserve data, and tmpfs is memory-backed and lost at stop.

    Open this question
  36. Question 36

    Automation, Orchestration, and Scripting

    What does docker compose down remove by default?

    Show the answer

    Correct answerA. The project's containers and networks, keeping its named volumes

    AWhy this is right: compose down removes the project's containers and networks and keeps named volumes so data survives.

    BWhy not this: Named volumes are removed only when -v or --volumes is added.

    CWhy not this: compose down also removes the networks it created for the project.

    DWhy not this: Images are removed only when --rmi is given.

    By default, down removes the project's containers and networks. Named volumes are kept so data survives, and are deleted only when -v (--volumes) is added; images are removed only with --rmi.

    Open this question
  37. Question 37

    Automation, Orchestration, and Scripting

    A script sets PREFIX=app and then runs echo $PREFIX_log, expecting app_log. The output is empty. Which change produces app_log?

    Show the answer

    Correct answerD. echo ${PREFIX}_log

    Without braces the shell reads PREFIX_log as the variable name, which is unset. Braces mark where the name ends. Using ${PREFIX_log} is tempting but still references the unset variable PREFIX_log.

    Open this question
  38. Question 38

    Automation, Orchestration, and Scripting

    A backup script must write to the directory in OUTDIR. If OUTDIR is unset or empty, the script should use /tmp/out for that one command, without assigning a value to OUTDIR. Which expansion meets this requirement?

    Show the answer

    Correct answerA. ${OUTDIR:-/tmp/out}

    The :- form substitutes the default when the variable is unset or empty and leaves the variable unchanged. The := form also yields the default but assigns it to OUTDIR, which the requirement rules out.

    Open this question
  39. Question 39

    Automation, Orchestration, and Scripting

    A script stores file=/backups/db_2024.tar.gz. The script needs only the file name, db_2024.tar.gz, with the directory portion removed. Which expansion produces it?

    Show the answer

    Correct answerC. ${file##*/}

    The ## operator removes the longest prefix matching */, leaving the text after the last slash. The single # form is tempting but removes only the shortest match, which is the leading slash, leaving backups/db_2024.tar.gz.

    Open this question
  40. Question 40

    Automation, Orchestration, and Scripting

    A monitoring script must store the number of entries in /data in a variable named count so it can be compared later. Which line does this correctly in Bash?

    Show the answer

    Correct answerC. count=$(ls /data | wc -l)

    Command substitution with $( ) runs the pipeline and replaces it with its output. Single quotes are the tempting wrong choice: they prevent any expansion, so count would hold the literal text of the command.

    Open this question
  41. Question 41

    Automation, Orchestration, and Scripting

    A script starts in /home/admin and runs the following line with MODE previously unset: (cd /tmp && export MODE=fast) The script then runs pwd and echo "$MODE". What do these two commands show?

    Show the answer

    Correct answerB. /home/admin and an empty MODE

    Parentheses run the commands in a subshell, so the directory change and the exported variable disappear when it exits. The parent shell stays in /home/admin with MODE unset. Only braces { ; } would run the commands in the current shell.

    Open this question
  42. Question 42

    Automation, Orchestration, and Scripting

    A technician is reviewing how Bash functions behave in a script. Which three statements are accurate? (Choose three.)

    Choose 3 answers

    Show the answer

    Correct answersA. A function must be defined earlier in the script than the line that calls it.B. A variable declared with local is limited to the function and the functions it calls.D. A variable assigned in a function without local remains set in the calling shell afterward.

    AWhy this is right: Bash runs a script line by line, so a call fails if the function has not been defined yet.

    BWhy this is right: Bash scoping is dynamic, so a local variable is visible to the function and the functions it calls.

    CWhy not this: return ends only the function and sets its exit status; exit is what ends the script.

    DWhy this is right: Variables in Bash are global by default, so an assignment without local stays set after the call.

    EWhy not this: $0 keeps the script name inside a function; the function name is in the FUNCNAME array.

    FWhy not this: return accepts only an integer status from 0 to 255; strings are passed back by echo and command substitution.

    Bash reads a script sequentially, so definitions must precede calls. Variables are global unless declared local, and local ones are scoped to the function and its callees. The return builtin only ends the function, not the script; exit ends the script. Inside a function $0 is still the script name (FUNCNAME holds the function name), and return takes only a number from 0 to 255.

    Open this question
  43. Question 43

    Automation, Orchestration, and Scripting

    A junior administrator is writing a Bash script and needs a function named backup that archives the directory passed as its first argument. Which definition is syntactically valid in Bash?

    Show the answer

    Correct answerB. backup() { tar -czf "$1.tgz" "$1"; }

    A name followed by () and a brace-enclosed body, with the last command ended by a semicolon, is valid. Omitting the semicolon before the closing brace is the tempting error, because Bash then reads the brace as an argument to tar.

    Open this question
  44. Question 44

    Automation, Orchestration, and Scripting

    A script defines the function cleanup_logs and then runs bash -c 'cleanup_logs'. The child shell reports "command not found". Which action makes the function available to the child shell?

    Show the answer

    Correct answerC. Run export -f cleanup_logs before starting the child shell

    The export -f option places a function in the environment so child Bash shells inherit it. Plain export applies to variables, not functions, which is why it is the tempting but ineffective choice.

    Open this question
  45. Question 45

    Automation, Orchestration, and Scripting

    A script is started with ./deploy.sh prod. It defines log_msg() { echo "[$1]"; } and later runs log_msg "starting". What does the function print?

    Show the answer

    Correct answerC. [starting]

    Inside a function, $1 refers to the function's own first argument, so it expands to starting. The script's argument prod is not visible as $1 there, which is the tempting wrong answer.

    Open this question
  46. Question 46

    Automation, Orchestration, and Scripting

    A function builds a report filename from the current date, and the calling script must store that string in a variable. Which approach correctly passes the string back to the caller?

    Show the answer

    Correct answerC. Print the filename with echo and capture it with command substitution

    A function writes its result to standard output, and the caller captures it with $(function_name). Using return is the tempting choice, but it only accepts an integer from 0 to 255 as an exit status, so it cannot carry a string.

    Open this question
  47. Question 47

    Automation, Orchestration, and Scripting

    A script runs set -- alpha beta gamma, then IFS=, on the next line, and then echo "$*". What does the echo command print?

    Show the answer

    Correct answerB. alpha,beta,gamma

    Inside double quotes, "$*" joins the positional parameters using the first character of IFS, which is now a comma. A space-separated result would only occur with the default IFS. Printing each parameter on its own line is not what "$*" does.

    Open this question
  48. Question 48

    Automation, Orchestration, and Scripting

    A script splits a comma-separated line into three variables with read. Later commands in the same script depend on the default word splitting of unquoted variables. Which approach splits the line without disturbing those later commands?

    Show the answer

    Correct answerD. IFS=, read -r a b c <<< "$line"

    Prefixing the assignment to read limits the changed IFS to that single command, so the shell's IFS stays at its default afterward. Setting IFS on its own line or exporting it changes it for the rest of the script, which breaks later word splitting.

    Open this question
  49. Question 49

    Automation, Orchestration, and Scripting

    A line of input has three leading spaces and three trailing spaces around its text. Which command stores the line in the variable line with those spaces kept?

    Show the answer

    Correct answerB. IFS= read -r line

    AWhy not this: -r only stops backslash interpretation; the default IFS still trims the leading and trailing spaces.

    BWhy this is right: An empty IFS stops read from trimming whitespace, and -r keeps backslashes literal.

    CWhy not this: With the default IFS, read strips leading and trailing spaces and tabs from the line.

    DWhy not this: IFS set to a space still makes read trim leading and trailing spaces.

    With IFS set to an empty string, read performs no field splitting and does not trim whitespace. With the default IFS, leading and trailing spaces and tabs are stripped. The -r option only stops backslash interpretation and has no effect on trimming.

    Open this question
  50. Question 50

    Automation, Orchestration, and Scripting

    A script must loop over each directory in $PATH, treating every directory as a separate array element. Which command builds that array?

    Show the answer

    Correct answerA. IFS=: read -ra dirs <<< "$PATH"

    IFS=: makes read split on colons, and -a stores each field as an array element. Without -a, a single variable receives the whole string. Without IFS=:, the default whitespace splitting finds no separators in PATH, so the array has one element.

    Open this question