Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 May 2008 16:11:01 -0300
From:      Mario Lobo <mario.lobo@ipad.com.br>
To:        freebsd-questions@freebsd.org
Subject:   Re: Unexepcted behavior from read and cat
Message-ID:  <200805121611.02108.mario.lobo@ipad.com.br>
In-Reply-To: <C1DFB4E8F62B503C9A829107@utd65257.utdallas.edu>
References:  <C1DFB4E8F62B503C9A829107@utd65257.utdallas.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On Monday 12 May 2008, Paul Schmehl wrote:
> I created a small list of IPs that I wanted to do digs on (because I'm la=
zy
> and don't want to do them one at a time.)
>
> I then wrote the following on the commandline:
>
> % dig +short -x `cat iplist`
>
> The results was an answer for the first line only.
>
> So, I thought read line would do the trick.  I tried this:
>
> % dig +short -x `(read line; echo $line; while read line; do echo $line;
> done) < iplist`
>
> Same result.
>
> I even tried:
>
> % dig +short -s `cat iplist | awk '{print $1}'`
>
> Same result.  (Yes, I know, why do twice the work to get the same answer,
> but I was desperate.)
>
> WTF?  Why do these utilities, which usually read all the lines in a file
> now only work once when run through dig?  Is there a way to feed dig a li=
st
> of IPs and have it return each and every one of them?
>
> I tried dig +short -x -f iplist, but that returns nothing at all.
>
> Sure, I can edit the file and prepend +short -x to each line, but by then=
 I
> might as well just do them individually.
>
> What am I missing?

Why not:

for ips in `cat iplist`
do
     dig +short -x $ips
done

=2D-=20
Mario Lobo
Seguran=E7a de Redes - Desenvolvimento e An=E1lise
IPAD - Instituto de Pesquisa e Apoio ao Desenvolvimento Tecnol=F3gico e=20
Cient=EDfico





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200805121611.02108.mario.lobo>