How to print only an IP address list of traceroute?

2

How do I print only an IP address list of a traceroute run?

I don't want the web addresses like something-online.net and their round trip times.

How do I get a "simple" traceroute from the terminal?

zcqwevb

Posted 2011-09-01T08:13:52.993

Reputation: 710

You need to add an example of what output you're currently seeing and what you are looking for. This is too vague. – Stuart McLaughlin – 2011-09-01T08:21:45.120

Answers

6

Are you looking for traceroute -n? From the man page:

   -n     Do not try to map IP addresses to  host  names  when  displaying
          them.

Edit: Comment added further requirement of removing round trip times.

To display everything except round trip times (sequence and IP address), CSV-formatted:

traceroute -n 8.8.8.8 | tail -n+2 | awk '{ print $1 "," $2 }'

Dave Sherohman

Posted 2011-09-01T08:13:52.993

Reputation: 5 143

yes, but how do I out it to a csv file without the round trip times in ms? – zcqwevb – 2011-09-01T08:25:16.897

Pipe the output into awk to print only the IP columns. – Gaff – 2011-09-01T08:31:28.370

1

Building on Dave Sherohman's answer. As I'm using using MinGW64, I only have access to tracert and not traceroute.

tracert uses the -d flag instead of the -n flag:

  -d                 Do not resolve addresses to hostnames.

And, here's some example output:

$ tracert -d 8.8.8.8 | tail -n+2 | awk '{ print $8 }'
of

10.7.7.1
169.57.0.194
169.57.118.132
50.97.19.110
50.97.19.113
50.97.16.37

108.170.231.15
8.8.8.8

rolandog

Posted 2011-09-01T08:13:52.993

Reputation: 66