|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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. -- Rahul |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
* Rahul <nospam@nospam.invalid>:
> 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. xargs For example: cmd1 | cmd2 | xargs -n1 ip2hex -- James Michael Fultz <xyzzy@sent.as.invalid> Remove this part when replying ^^^^^^^^ |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
> xargs
> For example: > cmd1 | cmd2 | xargs -n1 ip2hex Looks like I re-wrote a simpler version of xargs a month ago . . . learn something new everyday. Thanks for pointing out xargs. Chieh -- http://www.cynosurex.com/ |
|
![]() |
| Outils de la discussion | |
|
|