Date: Thu, 13 Oct 2005 01:35:43 -0400 (EDT) From: Peter Matulis <petermatulis@yahoo.ca> To: freebsd-questions <freebsd-questions@freebsd.org> Subject: Re: help with shell script Message-ID: <20051013053543.51718.qmail@web60016.mail.yahoo.com> In-Reply-To: <20051012204909.J78693@wolf.pjkh.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--- Philip Hallstrom <freebsd@philip.pjkh.com> wrote: > > 1. This gives me the amount of space (kB) taken up by the 10 largest ports: > > > > $ pkg_info -as | grep ^[0-9] | sort -gr | head -10 | cut -c 1-6 > > > > 2. Using one figure from above list I produce the details of the corresponding port: > > > > $ pkg_info -as | grep -B3 240695 > > > > Output: > > ------------------------------------------------------ > > Information for linux_base-8-8.0_6: > > > > Package Size: > > 240695 (1K-blocks) > > ------------------------------------------------------ > > > > I would like the output of the script to be the above but for all ten ports (~40 lines; > insert > > a blank line between each?). I know I need some sort of iteration but I am rusty on > scripting. > > Can anyone help? > > This should get you close... if you want only the top 10 just add more > pipes to the end with sort and head... > > ---------------------------------------------------- > #!/bin/sh > > newline='\ > ' > > pkg_info -as | \ > tr '\n' ' ' | \ > sed -e 's/Package Size://g' \ > -e "s/(1K-blocks)/$newline/g" |\ > sed -e 's/^ *Information for //' > ---------------------------------------------------- What I need is the size as the first item (not the second) on each line. Then I can use sort. __________________________________________________________ Find your next car at http://autos.yahoo.ca
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20051013053543.51718.qmail>