Search code examples
bashsedpiping

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

Solution

  • use this:

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