A Linux administrator is writing a Bash script that must safely process a list of filenames, some of which may contain spaces or special characters. The script reads each line from a file into a variable and then iterates over the entries. Which TWO practices should the administrator follow to avoid word-splitting and globbing issues? (Choose two.)
Quoting the variable expansion prevents the shell from performing word splitting and pathname expansion on the value. If a filename contains spaces or wildcard characters, an unquoted expansion would break it into multiple arguments or expand globs, causing the command to operate on the wrong files. Quoting preserves the value as a single argument.
Why this answer
To safely handle filenames with spaces or special characters, the script should quote variable expansions so the shell treats each value as a single argument, and read lines with IFS= read -r to preserve whitespace and backslashes. These two practices together prevent word splitting and globbing from corrupting the data during iteration.
Exam trap
The trap here is believing that globally changing IFS or using eval will solve quoting problems, when scoped quoting and IFS= read -r are the correct targeted techniques.