![]() |
Ciao e benvenuto da parte degli Stati Uniti al UNIX e Linux Forum! Grazie per la visita ed unirsi alla nostra Comunità Globale.
|
|
google unix.com
|
|||||||
| Forum | Registrati | Regole Forum | Collegamenti | Album | FAQ | Members List | Calendario | Ricerca | Today's Posts | Mark Forums Read |
| Shell scripting e di programmazione Pubblica domande su KSH, CSH, SH, Bash, Perl, PHP, sed, awk e da altri script di shell e linguaggi di scripting shell qui. |
Più di UNIX e Linux Forum Argomenti potreste trovare utili
|
||||
| Filo | Thread Starter | Forum | Risposte | Ultimo Post |
| Perl analisi rispetto a ksh parsing | Popeye | Shell scripting e di programmazione | 1 | 08-06-2008 10:46 PM |
| linee di lettura in coppia da file in ksh | ytokar | Shell scripting e di programmazione | 4 | 02-08-2008 02:50 PM |
| perl di ricerca e sostituzione di coppie di | umen | Shell scripting e di programmazione | 1 | 07-30-2006 11:37 AM |
| proc | bache_gowda | UNIX for Dummies Domande & Risposte | 7 | 05-23-2005 11:18 AM |
| /proc | aojmoj | UNIX e avanzata per utenti esperti | 3 | 11-20-2002 05:54 PM |
|
|
LinkBack | Thread Tools | Cerca in questo Thread | Rate Thread | Modalità di visualizzazione |
|
||||
|
Ciao a tutti,
Ho bisogno di aiuto con l'uso sed/awk / linux altri strumenti per soddisfare i seguenti obiettivi: Sto cercando di prendere l'output di / proc / net / dev: Codice:
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
lo:18748525 129811 0 0 0 0 0 0 18748525 129811 0 0 0 0 0 0
eth0:1699369069 226296437 0 0 0 0 0 3555 4118745424 194001149 0 0 0 0 0 0
eth1: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
sit0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Codice:
rxbytes:1699369069 rxpackets:226296437 rxerrs:0 rxdrop:0 rxfifo:0 rxframe:0 rxcompressed:0 rxmulticast:3555 \ txbytes:4118745424 txpackets:194001149 txerrs:0 txdrop:0 txfifo:0 txcolls:0 txcarrier:0 txcompressed:0 Codice:
cat /proc/net/dev | egrep "(eth0|face)" | sed -e 's/|/:/' | sed -e 's/|/ /' | cut -d ":" -f 2 | tr -s " " " " bytes packets errs drop fifo frame compressed multicast bytes packets errs drop fifo colls carrier compressed 1709184740 226328683 0 0 0 0 0 3555 4122564415 194035769 0 0 0 0 0 0 La tua esperienza è molto apprezzato! Aggiornamento: Ho trovato il modo di recepire le righe in colonne (che è un passo avanti!): Codice:
cat /proc/net/dev | egrep "(eth0|face)" | sed -e 's/|/:/' | sed -e 's/|/ /' | cut -d ":" -f 2 | tr -s " " " " | \
awk 'BEGIN {FS=" "} {for (i=1;i<=NF;i++){ arr[NR,i]=$i; if(big <= NF) big=NF; }} \
END {for(i=1;i<=big;i++){for(j=1;j<=NR;j++){printf("%s:",arr[j,i]);}printf("\n");}}'
bytes:1718395341:
packets:226353349:
errs:0:
drop:0:
fifo:0:
frame:0:
compressed:0:
multicast:3555:
bytes:4126856358:
packets:194063589:
errs:0:
drop:0:
fifo:0:
colls:0:
carrier:0:
compressed:0:
Update 2: I got it! L'unico modo in cui potrebbe essere meglio con CamelCase (RxBytes, ecc): Codice:
cat /proc/net/dev | egrep "(eth0|face)" | sed -e 's/|/:/' -e 's/|/ /' | cut -d ":" -f 2 | tr -s " " " " | \
awk 'BEGIN {FS=" "} {for (i=1;i<=NF;i++){ if(i<9){arr[NR,i]="rx"$i;}else{arr[NR,i]="tx"$i;} if(big <= NF) big=NF; }} \
END {for(i=1;i<=big;i++){for(j=1;j<=NR;j++){ printf("%s\t",arr[j,i]);}printf("\n");}}' | sed -e 's/\t$//' -e 's/\t/:/' -e 's/:[tr]x/:/'
rxbytes:1790844622
rxpackets:226585666
rxerrs:0
rxdrop:0
rxfifo:0
rxframe:0
rxcompressed:0
rxmulticast:3555
txbytes:4161116750
txpackets:194310608
txerrs:0
txdrop:0
txfifo:0
txcolls:0
txcarrier:0
txcompressed:0
Ultimo a cura di otheus; al 01/30/2009 07:31 AM.. Motivo: Woot! |
| Segnalibri |
| Tag |
| irrisolti, sospeso per mesi, irrisolti per settimane |
| Thread Tools | Cerca in questo Thread |
| Modalità di visualizzazione | Vota questo thread |
|
|