View Single Post

  #7 (permalink)  
Old 05-02-2008
Bill Marcum
 
Posts: n/a
Default Re: feeding a series of input args to a command that only takes one

On 2008-05-01, Rahul <nospam@nospam.invalid> wrote:
>
>
> Sometimes I have commands that are designed only to process a single
> input argument but I want to call them repeatedly on a list.
>
> For example I generate a command line pipe that outputs a list of ip
> addresses:
>
> cmd1 | cmd2 | tr '\n' '\t'
>
> 11.0.0.21 11.0.0.176 11.0.0.191
>
> To convert to hex I have ip2hex that accepts only 1 arg. ip2hex: ip2hex
><ip address>
>
> Is there a command line metaphor to feed a command one arg at a time
> repeatedly. I guess I could use a for loop but that's somewhat unweildly
> on the command line.
>

while read ip_address
Reply With Quote