Compare an A record across three public DNS resolvers
Build a paste-ready command, then review its compatibility and effects before running it.
for resolver in 1.1.1.1 8.8.8.8 9.9.9.9; do printf '%-9s ' "$resolver"; dig +short @${resolver} <domain> A | paste -sd, -; doneComplete required fields to copy the generated command.
Compatibility
Linux + macOSVerified for Linux, macOS using bash, zsh syntax.
Operational knowledgereview due 2027-01-19
Requirementsforfor must be installed and available on PATH.Network accessThe target must be reachable from the current environment.
Version supportfor Current supported releasesVerified for linux, macos using bash, zsh syntax; consult compatibility notes for platform-specific differences.
Expected signals1.1.1.1 93.184.216.34Representative successful output; values vary with the selected target and system state.
Known errorsfor: command not foundfor is missing or is not available on PATH.
Verifyfor resolver in 1.1.1.1 8.8.8.8 9.9.9.9; do printf '%-9s ' "$resolver"; dig +short @${resolver} {{domain}} A | paste -sd, -; doneThe output matches the expected target and exits without an error.Rollback noteNot required: this command is read-only and does not change system state.
Command breakdown
01forShell loopStarts a loop that repeats the following body for each value.
02resolverArgumentPasses resolver to this command.
03inLoop valuesIntroduces the values assigned to the loop variable.
041.1.1.1ArgumentPasses 1.1.1.1 to this command.
058.8.8.8ArgumentPasses 8.8.8.8 to this command.
069.9.9.9ArgumentPasses 9.9.9.9 to this command.
07;Command separatorEnds this shell statement before the next one begins.
08doLoop bodyStarts the commands executed for each loop value.
09printfCommandRuns the printf stage of this one-liner.
10'%-9s 'ArgumentPasses '%-9s ' to printf.
11"$resolver"ArgumentPasses "$resolver" to printf.
12;Command separatorEnds this shell statement before the next one begins.
13digCommandRuns the dig stage of this one-liner.
14+shortOptionRequests concise output without the normal diagnostic sections.
15@${resolver}ArgumentPasses @${resolver} to dig.
16<domain>ParameterA value supplied in the Fill parameters section.
18|PipelinePasses the output on the left to the command on the right.
19pasteCommandRuns the paste stage of this one-liner.
20-sd,OptionConfigures paste with the -sd, option.
21-OptionConfigures paste with the - option.
22;Command separatorEnds this shell statement before the next one begins.
23doneEnd loopCloses the shell loop.
This advanced community-curated one-liner combines several stages. Review every option and placeholder before running it.
Example input
for resolver in 1.1.1.1 8.8.8.8 9.9.9.9; do printf '%-9s ' "$resolver"; dig +short @${resolver} example.com A | paste -sd, -; done
Example output
1.1.1.1 93.184.216.34
8.8.8.8 93.184.216.34
9.9.9.9 93.184.216.34
Illustrative output — exact values vary by system and data.
Official sources