From owner-freebsd-questions@FreeBSD.ORG Fri Jan 18 18:54:59 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2550C16A418 for ; Fri, 18 Jan 2008 18:54:59 +0000 (UTC) (envelope-from annkok2001@yahoo.com) Received: from web53310.mail.re2.yahoo.com (web53310.mail.re2.yahoo.com [206.190.49.100]) by mx1.freebsd.org (Postfix) with SMTP id 6394713C459 for ; Fri, 18 Jan 2008 18:54:58 +0000 (UTC) (envelope-from annkok2001@yahoo.com) Received: (qmail 36195 invoked by uid 60001); 18 Jan 2008 18:28:16 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=vUVzOFZvDMOc6YiWdmsd0PIZJ+bVVfyxKaCgwsYdHd07dfH/D0spGIcNkGh3FfY6uWVx7Dfex7BaToWL/zdLQK+n8y0Ni9iixjBic7uQsZB/wJPm4HjidCrMCnm+uwyGBo/m7Z8FxMwG4k2kruu95WGcuqHems8iaWOi1A7LTdA=; X-YMail-OSG: XIIn8EIVM1kF0.YQ9ZvZizrQcNAji6WW.Fs30ck61SHK4swfrpiSk9DFX6M2MHklhKIFDdu7ZlHy824sc3Rrh6ubibvviJBUzcwBSbcZ_hb5vMH3BJJ5rz6kdBdP1vdoG6U3fwPDztgVZpCeYaqAFA-- Received: from [66.49.254.13] by web53310.mail.re2.yahoo.com via HTTP; Fri, 18 Jan 2008 10:28:16 PST Date: Fri, 18 Jan 2008 10:28:16 -0800 (PST) From: ann kok To: fbsdq@peterk.org, Paul Schmehl In-Reply-To: <1354.63.65.46.186.1200677645.squirrel@webmail.pknet.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <174078.33010.qm@web53310.mail.re2.yahoo.com> Cc: FreeBSD Questions Subject: Re: Shell scripting kungfu X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Jan 2008 18:54:59 -0000 how about this cat file | sed 's/\/32//g' |tr -s "," "\n" --- fbsdq@peterk.org wrote: > > I need to do the following: > > > > Take a list of various strings, one of which is a > quoted IP address, and > > extract the IPs. (Done that.) > > > > Then take the list of IPs and convert them to a > list of IPs with masks on > > a > > single line. > > > > IOW, I have converted the original list to this: > > > > x.x.x.x > > x.x.x.x > > x.x.x.x > > x.x.x.x > > > > Now I need to remove the newlines and add /32, to > the end of each IP so > > that I > > have this: > > x.x.x.x/32,x.x.x.x/32,x.x.x.x/32,etc. > > > > I got close with sed, but I'm not quite there. > > > > I got this: > > > > x.x.x.x/32,x.x.x.x > > x.x.x.x/32,x.x.x.x > > x.x.x.x/32,x.x.x.x > > > > Here's the code I used: > > cat hostlist | cut -d',' -f2 | cut -d'"' -f2 | > sort | uniq | grep -v > > "inet" | > > sed '/[^*]$/N;s/\n */\/32,/' > > > > What am I missing? > you are missing 'tr' I guess; > > chernogorsk:#cat /tmp/x > x.x.x.x > x.x.x.x > x.x.x.x > x.x.x.x > chernogorsk:#cat /tmp/x | sed 's/$/\/32,/g'|tr -d > "\r\n" > /tmp/x2; echo > >> /tmp/x2 > chernogorsk:#cat /tmp/x2 > x.x.x.x/32,x.x.x.x/32,x.x.x.x/32,x.x.x.x/32, > > some fine tunning and getting rid of the trailing > ',' you can add another > sed pipe, etc.etc. > > ]Peter[ > > > > > > > > > > > > -- > > Paul Schmehl (pauls@utdallas.edu) > > Senior Information Security Analyst > > The University of Texas at Dallas > > http://www.utdallas.edu/ir/security/ > > > > _______________________________________________ > > freebsd-questions@freebsd.org mailing list > > > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > > To unsubscribe, send any mail to > > "freebsd-questions-unsubscribe@freebsd.org" > > > > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to > "freebsd-questions-unsubscribe@freebsd.org" > ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping