Sunday, May 5, 2024
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 1528  / 1 Year ago, thu, november 24, 2022, 10:05:29

I am using DIG command in linux and getting results i want but how can i get output results written in CSV file and get them saved ?



Current output is below which i want in csv file :



inspectieSZW.nl.        19      IN      A       178.22.85.166
inspectieSZW.nl. 19 IN A 178.22.85.169
belgique.be. 6940 IN A 193.191.245.244
belgie.be. 6940 IN A 193.191.245.244
christiemorreale.be. 3340 IN A 128.65.195.89
regards.fr. 340 IN A 137.74.167.22
dragons.jp. 19 IN A 52.198.194.108
dragons.jp. 19 IN A 18.182.191.127
j-sm.jp. 79 IN A 49.212.243.98
ndenter.co.kr. 3341 IN A 223.26.138.51
semillasdelfuturo.com.co. 341 IN A 50.62.88.87
redesdamare.org.br. 3342 IN A 149.56.157.48

More From » command-line

 Answers
2

Enter every dig command like this (replace [HOSTNAME] by the host name you want to DIG):



dig [HOSTNAME] | grep IN | grep -v ";" | tr -s "[:blank:]" "," >> savedoutput.csv



  1. The first grep leaves only the lines containing "IN".

  2. The second grep removes the line starting with ; in the QUESTION SECTION.

  3. The tr command replaces all spaces by commas.

  4. The >> appends all output to the file called savedoutput.csv.


[#3689] Friday, November 25, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
uccase

Total Points: 473
Total Questions: 100
Total Answers: 110

Location: Anguilla
Member since Sun, Jan 29, 2023
1 Year ago
uccase questions
;