> From: John W. Krahn [mailto:[EMAIL PROTECTED] > Sent: 10 November 2008 11:26 > To: Perl Beginners > Subject: Re: Using perl in a Bash-script to extract IP-addresses? > > Stewart Anderson wrote: > >> JC Janos wrote: > >>> > >>> I have a file containing IP addresses & ranges, their negations, and > >>> comments. E.g., > >>> > >>> 1.1.1.1 # comment A > >>> 2.2.2.2/29 # comment B > >>> !3.3.3.3 # comment C > >>> !4.4.4.4/28 # comment D > >>> > >>> I need to extract those IPs & ranges, rearrange them into a > >>> comma-separated list, e.g., > >>> > >>> 1.1.1.1,2.2.2/29,!3.3.3.3,!4.4.4.4/28 > >>> > >>> I've read that Perl (which I don't know yet at all) is "best" for > > Text > >>> processing like this. > >>> > >>> The thing is that I need to do this from within a Bash script, and > >>> assign the comma-separated list to a variable in that Bash script. > > > > Here is an example of the same thing in shell speak just do whatever > > you want with. The ipaddy in the loop to purduce the string you > > require. > > > > > > cat ipin.txt |while read inline > > do ipaddy=`echo $inline |awk '{print $1 } '` > > echo $ipaddy > > done > > Why not just: > > ipaddy=`awk '{ print $1 }' ipin.txt` > > > But that still doesn't get you a comma-separated list. > > >
Never said it did, I did suggest to build the string in the loop > > Here is an example of the same thing in shell speak just do whatever > > you want with. The ipaddy in the loop to purduce the string you > > require. > > :) Information in this email including any attachments may be privileged, confidential and is intended exclusively for the addressee. The views expressed may not be official policy, but the personal views of the originator. If you have received it in error, please notify the sender by return e-mail and delete it from your system. You should not reproduce, distribute, store, retransmit, use or disclose its contents to anyone. Please note we reserve the right to monitor all e-mail communication through our internal and external networks. SKY and the SKY marks are trade marks of British Sky Broadcasting Group plc and are used under licence. British Sky Broadcasting Limited (Registration No. 2906991), Sky Interactive Limited (Registration No. 3554332), Sky-In-Home Service Limited (Registration No. 2067075) and Sky Subscribers Services Limited (Registration No. 2340150) are direct or indirect subsidiaries of British Sky Broadcasting Group plc (Registration No. 2247735). All of the companies mentioned in this paragraph are incorporated in England and Wales and share the same registered office at Grant Way, Isleworth, Middlesex TW7 5QD. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/