shell scripting gurus?

Smoot Carl-Mitchell smoot at tic.com
Thu Jun 5 17:19:48 UTC 2008


On Thu, 2008-06-05 at 10:41 -0500, Les Mikesell wrote:
> Bart Silverstrim wrote:
> > If I have a file of IP addresses, one per line, is there an easy way to 
> > have a shell script read each line and perform an operation that plugs 
> > that IP into another command?
> 
> while read $IP
>   do
>    something $IP
>   done < file_name
> 
> (assuming it doesn't hurt to redirect stdin for the whole loop)

Not quite.  The argument to read is a shell variable.

while read IP; do
   something $IP
done < file_name

The '$' tells the shell to interpolate the value of the variable IP.

-- 
Smoot Carl-Mitchell
System/Network Architect
smoot at tic.com
+1 480 922 7313
cell: +1 602 421 9005




More information about the ubuntu-users mailing list