shell scripting gurus?

Les Mikesell lesmikesell at gmail.com
Thu Jun 5 21:25:10 UTC 2008


Smoot Carl-Mitchell 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.

I should know better than to post something without trying it... I 
always get it backwards in perl too, where it does want the $ on the 
assignments.

-- 
   Les Mikesell
    lesmikesell at gmail.com




More information about the ubuntu-users mailing list