0

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
agc
  • 7,973
  • 2
  • 29
  • 50
Hansi
  • 127
  • 1
  • 8
  • 1
    Possible duplicate of [Linux command output as a parameter of another command](http://stackoverflow.com/questions/13236344/linux-command-output-as-a-parameter-of-another-command) – tripleee Jun 30 '16 at 11:30

2 Answers2

1

use this:

sed -e 's/^[[:digit:]]*,//' FILE  | xargs -I {} dig {}  AAAA +short 
Baba
  • 852
  • 1
  • 17
  • 31
0

Using cut & GNU parallel:

cut -d',' -f2 hostnames  | parallel 'dig {}  AAAA +short'
agc
  • 7,973
  • 2
  • 29
  • 50