O
O
Oleg2021-07-01 11:35:16
bash
Oleg, 2021-07-01 11:35:16

How to cut extra from ANSWER SECTION to dig?

My question is this. I execute a request -
dig +nocmd -x 94.100.180.201 +noall +answer

I receive a response -

201.180.100.94.in-addr.arpa      2312      IN      PTR       mail.ru.


How can I remove from the response - 2312 IN PTR

leaving a record like - 201.180.100.84.in-addr.arpa mail.ru.

I would be very grateful for ideas.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oleg, 2021-07-01
@molekulo

Here is a 100% working solution.

#!/bin/bash
cat ip_list.txt | while read LINE; do
           ip=`echo ${LINE}|awk '{print $1}'`
           fqdn="$(/usr/bin/dig -x $ip +short| head -n 1)"
           echo "$ip $fqdn"
           done>ip_to_fqdn.txt

K
klltmchn, 2021-07-01
@klltmchn

dig +nocmd -x 94.100.180.201 +noall +answer | awk '{print $1}'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question