Re: Shell, comandos grep y awk
On Fri, Sep 10, 2004 at 08:33:11PM +0200, Iñaki wrote:
> /sbin/ifconfig eth0 | grep 'RX byte' | awk '{print $7 $8}'
Soy un pésimo programador bash/awk... mi solución está basada en PERL:
/sbin/ifconfig eth0 | grep 'RX byte' | awk '{print $7 $8}'|perl -e
'$_=<STDIN>; s/[\(|\)]//g; print;'
eso te saca los paréntesis del modo que querés. De todas formas para hacerlo
en PERL pero de un solo golpe:
/sbin/ifconfig eth0|perl -e '@_=<STDIN>; $_= $_[6]; split /[ ]+/; $_ = $_[3];
s/[\(|\)]//g; print'
> 58.2 MB
> 750.5 KB
> 1.2 GB
Complicándolo un poco más podés sacar otros valores... decime cuáles querés y
te hago un scriptecito más completo.
Saludos,
Félix
--
Felix Cuello
felix@qodiga.com
- 1432 -
Q: How do you know when you're in the <ethnic> section of Vermont?
A: The maple sap buckets are hanging on utility poles.
Reply to: