Hansi
Hansi

Reputation: 137

Process sed-(stream editor)-output further

I'm a bash-scripting newbie and don't even know how to formulate my question. I've skimmed this tutorial, but couldn't find an appropriate code example. This is what I want...

I have a list of hostnames, (hostname being google.com and such), which looks like:

1,hostname_1
2,hostname_2
...
n,hostname_n

I want to remove the number in the front, that can be easily done with:

originList="originList.txt"
preparedList="preparedList.txt"
ipv6list="ipv6list.txt"

sed 's/[0-9]*,//' <$originList >$preparedList

But instead of piping the output to preparedList.txt I'd like to use it in my dig command:

sed 's/[0-9]*,//' <$originList | dig **HERE** AAAA +short >> $ipv6List

Upvotes: 0

Views: 30

Answers (2)

agc
agc

Reputation: 8446

Using cut & GNU parallel:

cut -d',' -f2 hostnames  | parallel 'dig {}  AAAA +short'

Upvotes: 0

Baba
Baba

Reputation: 850

use this:

sed -e 's/^[[:digit:]]*,//' FILE  | xargs -I {} dig {}  AAAA +short 

Upvotes: 1

Related Questions