0

In my example, I have the following line in the script:

output=$(nslookup -type=txt "$domain")   # in this example, $domain contains cnn.com
     # so the actual command is: nslookup -type=txt cnn.com <return>
   echo $output

Except the output contains multiple lines, when echo'ed, shows up as one big line without the CR/LF

What I want to be able to do is process each line that contains "$domain text = "some text" \n Could you recommend a way to process the return data so its formatted correctly, and if the line contains "$domain text = " to process it?

Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
  • Use dig: `dig -t TXT "$domain" +short` – jordanm Jan 12 '22 at 18:53
  • I'm closing as duplicate of the underlying shell problem, but as @jordanm's comment points out, this is more of an [XY problem](https://xyproblem.info/). – Benjamin W. Jan 12 '22 at 18:57
  • When I execute the command "dig -t TXT yahoo.com +short" the results are on each new line, as expected. However, when I call it from within the bash script, the output appears as one long line rather than multiple lines. – Cyb3r0yst3r Jan 12 '22 at 20:11
  • Neither nslookup nor dig are designed to be used in scripts to parse their results, you will get all sorts of problems. – Patrick Mevzek Jan 12 '22 at 23:55

0 Answers0