[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Shell, comandos grep y awk



Esto lo probe y funcionó...quizas se pueda hacer sin repetir el sed.. 

 /sbin/ifconfig eth0 | grep 'RX byte' | awk '{print $7 " " $8}' |sed -e
's/i//' |sed -e 's/(//' |sed -e 's/)//'

Saludos..

El vie, 10-09-2004 a las 15:46, Felix Cuello escribió:
> 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.
> 

Attachment: signature.asc
Description: Esta parte del mensaje =?ISO-8859-1?Q?est=E1?= firmada digitalmente


Reply to: