ok, thanks! (i'll try to reduce my useless cats)<br>but awk syntax is really "awkward" ;-) do you know a bright guide for awk? (please not man awk...)<br>d<br><br><div class="gmail_quote">On Sun, Jul 26, 2009 at 10:12 PM, Rui Miguel Silva Seabra <span dir="ltr"><<a href="mailto:rms@1407.org">rms@1407.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Because you launched 1 program then 4 programs in background, which<br>
are fed to a while loop => much memory + cpu usage.<br>
<br>
With... opkg list_upgradable | awk '!/(kernel|Multiple)/ {print $1}'<br>
<br>
... you now launch less 3 programs than before (two greps and one cat),<br>
while feeding exactly the same output to the while loop. :)<br>
<br>
If you grep then awk or awk then grep, then 99% of the time you're<br>
uselessly greping. Awk greps better than grep, specially when you<br>
want to transform the output :)<br>
<br>
Also a nice read: Useless use of cat<br>
<a href="http://www.google.pt/search?q=useless+use+of+cat" target="_blank">http://www.google.pt/search?q=useless+use+of+cat</a><br>
<font color="#888888"><br>
Rui<br>
</font><div><div></div><div class="h5"><br>
On Sun, Jul 26, 2009 at 09:40:26PM +0200, Davide Scaini wrote:<br>
> he he this is the power of opensource...<br>
> why you said that is heavy? (i just want to learn, i'm quite newbie in<br>
> scripting and expecially using awk...)<br>
> d<br>
><br>
> On Sun, Jul 26, 2009 at 8:29 PM, Rui Miguel Silva Seabra <<a href="mailto:rms@1407.org">rms@1407.org</a>>wrote:<br>
><br>
> > On Sun, Jul 26, 2009 at 07:18:07PM +0100, Rui Miguel Silva Seabra wrote:<br>
> > > On Sun, Jul 26, 2009 at 07:49:19PM +0200, Davide Scaini wrote:<br>
> > > > I want to share my little bash script to update shr without distroying<br>
> > my<br>
> > > > existing kernel (a true 2.6.28).<br>
> > > > It's really stupid, but maybe someone could find it interesting.<br>
> > > ><br>
> > > > opkg list_upgradable > upgradable<br>
> > > ><br>
> > > > cat upgradable | awk '{print $1}' | grep -v kernel | grep -v Multiple |<br>
> > > > while read line<br>
> > > ><br>
> > > > do echo "installing pack $line"<br>
> > > > opkg install $line<br>
> > > > done<br>
> > > ><br>
> > > > I have a script called upgrade.sh and I run that one. If you don't want<br>
> > to<br>
> > > > update for example tangogps (or wathever) just add<br>
> > > > grep -v tangogps |<br>
> > > > just before "while read line"...<br>
> > ><br>
> > > Nice. But a little heavy on the little Neos :) May I suggest a possible<br>
> > > alternative?<br>
> ><br>
> > oops a mistake, this one is corrected, though:<br>
> ><br>
> > opkg list_upgradable | awk '!/(kernel|Multiple)/ {print $1}' | \<br>
> > while read line; do<br>
> > echo "installing pack $line"<br>
> > opkg install $line<br>
> > done<br>
> ><br>
> > Rui<br>
> ><br>
> > _______________________________________________<br>
> > Openmoko community mailing list<br>
> > <a href="mailto:community@lists.openmoko.org">community@lists.openmoko.org</a><br>
> > <a href="http://lists.openmoko.org/mailman/listinfo/community" target="_blank">http://lists.openmoko.org/mailman/listinfo/community</a><br>
> ><br>
<br>
> _______________________________________________<br>
> Openmoko community mailing list<br>
> <a href="mailto:community@lists.openmoko.org">community@lists.openmoko.org</a><br>
> <a href="http://lists.openmoko.org/mailman/listinfo/community" target="_blank">http://lists.openmoko.org/mailman/listinfo/community</a><br>
<br>
<br>
</div></div>--<br>
<div><div></div><div class="h5"><br>
_______________________________________________<br>
Openmoko community mailing list<br>
<a href="mailto:community@lists.openmoko.org">community@lists.openmoko.org</a><br>
<a href="http://lists.openmoko.org/mailman/listinfo/community" target="_blank">http://lists.openmoko.org/mailman/listinfo/community</a><br>
</div></div></blockquote></div><br>