This is a discussion on feeding a series of input args to a command that only takes one within the Linux General forums, part of the Linux Forums category; Icarus Sparry <usenet@icarus.freeuk.com> wrote in news:481ab188$0$34548 $742ec2ed@news.sonic.net: > > ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Icarus Sparry <usenet@icarus.freeuk.com> wrote in news:481ab188$0$34548
$742ec2ed@news.sonic.net: > > cmd1 | cmd2 | while read ip ; do ip2hex $ip ; done Thanks guys for all those leads! I think xargs works perfect. Does my job. Just out of curiosity though: I haven't been able to hack together the while read oneliner that would do the same job: echo "11.0.0.1 \n 11.0.0.2 \n 11.0.0.3" | while read ip ; do ip2hex $ip ; done Only does the first address. Even tried: echo "11.0.0.1 11.0.0.2 11.0.0.3" | while read ip ; do ip2hex $ip ; done What's the correct form? -- Rahul |
|
|||
|
Rahul wrote:
> Icarus Sparry <usenet@icarus.freeuk.com> wrote in news:481ab188$0$34548 > $742ec2ed@news.sonic.net: > >> cmd1 | cmd2 | while read ip ; do ip2hex $ip ; done > > Thanks guys for all those leads! I think xargs works perfect. Does my > job. Just out of curiosity though: I haven't been able to hack together > the while read oneliner that would do the same job: > > echo "11.0.0.1 \n 11.0.0.2 \n 11.0.0.3" | while read ip ; do ip2hex $ip > ; done > > Only does the first address. Even tried: > > echo "11.0.0.1 11.0.0.2 11.0.0.3" | while read ip ; do ip2hex $ip ; > done > > What's the correct form? Supply only one IP number per line. The "read" command will read a complete line on each invocation. Compare: kees@lankhmar:~$ echo "11.0.0.1 \n 11.0.0.2 \n 11.0.0.3" 11.0.0.1 \n 11.0.0.2 \n 11.0.0.3 with: kees@lankhmar:~$ echo -e "11.0.0.1 \n 11.0.0.2 \n 11.0.0.3" 11.0.0.1 11.0.0.2 11.0.0.3 Regards, Kees. -- Kees Theunissen. |