Re: help with shell script
in message <[EMAIL PROTECTED]>, wrote Peter Matulis thusly... Could your please wrap lines around 69 or so characters? > What I need is the size as the first item (not the second) on each > line. Then I can use sort. You can easily specify the column|key to sort on via -k flag ... { echo "polka 1" ; echo "dot 4"; } \ | sort -k2,2nr - Parv -- ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: help with shell script
in message <[EMAIL PROTECTED]>, wrote Philip Hallstrom thusly... > > #!/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 //' Holy cow, i was going about it all wrong! No wonder it was taking me too long for this; i was parsing some things instead of removing others. - Parv -- ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: help with shell script
--- Peter Matulis <[EMAIL PROTECTED]> wrote: > > --- Philip Hallstrom <[EMAIL PROTECTED]> 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. Allrighty, I employed some awk to get a good enough output: #!/bin/sh newline='\ ' pkg_info -as | \ tr '\n' ' ' | \ sed -e 's/Package Size://g' \ -e "s/(1K-blocks)/$newline/g" | \ tr ':' ' ' | \ awk '{print$4," ",$3}' | \ sort -gr | \ head -30 Thanks. __ Find your next car at http://autos.yahoo.ca ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: help with shell script
--- Philip Hallstrom <[EMAIL PROTECTED]> 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 ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: help with shell script
Hi. I am writing up a doc for the fbsd community that covers usage of ports. I have two commands that allow me to assertain the amount of disk space being utilized by currently installed ports. I would like to make a shell script (bourne or bash) out of them but I am not sure how. 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 //' ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"
help with shell script
Hi. I am writing up a doc for the fbsd community that covers usage of ports. I have two commands that allow me to assertain the amount of disk space being utilized by currently installed ports. I would like to make a shell script (bourne or bash) out of them but I am not sure how. 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 Example output: -- 240695 59274 55526 54271 47418 42644 35364 31091 29181 28745 -- 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? __ Find your next car at http://autos.yahoo.ca ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"