The UNIX and Linux Forums  


Go Back   UNIX e Linux Forum > Inizio Forum > Shell scripting e di programmazione
.
google unix.com



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
Come Calcolare krishna_sicsr Shell scripting e di programmazione 3 03-21-2009 01:49 PM
calcolare lo spazio za_7565 Shell scripting e di programmazione 8 05-04-2008 08:22 AM
Come calcolare con awk whatisthis Shell scripting e di programmazione 4 11-09-2005 12:39 PM
calcolare le dimensioni di alcuni file big123456 Shell scripting e di programmazione 11 07-22-2005 06:07 PM
Come calcolare una somma di alcune registrazioni? sickboy Shell scripting e di programmazione 10 06-10-2005 12:43 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Cerca in questo Thread Rate Thread Modalità di visualizzazione
  #1 (permalink)  
Old 01-08-2008
koti_rama koti_rama is offline
Utente Registrato
  
 

Iscriviti Data: giugno 2007
Posti: 50
calcolare da tre file

Ciao a tutti
Ho 3 tre file come:
file1:

1 | 100
2 | 200
3 | 300
4 | 400
5 | 500

file2:
1 | 200
2 | 200
3 | 600
4 | 800


file3:
1 | 300
2 | 100
3 | 200


Vorrei mettere in atto come:
1 | 100 | 200 | 300 | 0
2 | 200 | 200 | 100 | 100
3 | 300 | 600 | 200 | 700
4 | 400 | 800 | 0 | 1200


Senario:

come i wolud

file1.column2 + file2.cloumn2-file3.cloumn2

please help me su questo punto.
  #2 (permalink)  
Old 01-08-2008
ghostdog74 ghostdog74 is offline Forum Advisor  
Utente Registrato
  
 

Join Date: Sep 2006
Interventi: 2.556
che cosa hai provato?
  #3 (permalink)  
Old 01-08-2008
dennis.jacob dennis.jacob is offline Forum Advisor  
dj - lo studente
  
 

Iscriviti Data: febbraio 2007
Ubicazione: Singapore / Bangalore / Cochin
Messaggi: 610

Codice:
paste file1 file2 file3 |sed 's/|/ /g'|awk '{ if ($6=="") $6=0;if ($4=="") $4=0; if ($2=="") $2=0;print $1 "|" $2 "|" $4 "|" $6"|"$2+$4-$6;}'

Uscita:

Citazione:
1 | 100 | 200 | 300 | 0
2 | 200 | 200 | 100 | 300
3 | 300 | 600 | 200 | 700
4 | 400 | 800 | 0 | 1200
5 | 500 | 0 | 0 | 500
  #4 (permalink)  
Old 01-08-2008
koti_rama koti_rama is offline
Utente Registrato
  
 

Iscriviti Data: giugno 2007
Posti: 50
grazie ......
  #5 (permalink)  
Old 01-08-2008
jaduks's Avatar
jaduks jaduks is offline
Utente Registrato
  
 

Join Date: Aug 2007
Ubicazione: Assam, in India
Interventi: 167
$ Pasta-d "|" filex Filey Filez | awk '
> OFS BEGIN (FS \u003d \u003d"|"} (print $ 1, $ 2, $ 4, $ 6, $ 2 + $ 4 - $ 6)
> '| Awk' BEGIN (FS \u003d OFS \u003d"|"}{ for (i \u003d 0; i <\u003d NF; i + +)
> If ($ i \u003d\u003d "")
> $ I \u003d 0
> Print $ 0) '


<Output>
1 | 100 | 200 | 300 | 0
2 | 200 | 200 | 100 | 300
3 | 300 | 600 | 200 | 700
4 | 400 | 800 | 0 | 1200
5 | 500 | 0 | 0 | 500
  #6 (permalink)  
Old 01-08-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Iscriviti Data: gennaio 2007
Ubicazione: Варна, България / Milano, Italia
Messaggi: 2.926
Un altro:


Codice:
awk '
!f { f2[$1] = $2; next }
f == 3 { f3[$1] = $2; next }
f == 1 { $3 = (f2[$1] ? f2[$1] : 0)
    $4 = (f3[$1] ? f3[$1] : 0)
    $5 = $2 + f2[$1] - f3[$1]
}1' FS="|" OFS="|" file2 f=3 file3 f=1 file1

Closed Thread

Segnalibri

Thread Tools Cerca in questo Thread
Cerca in questo Thread:

Ricerca Avanzata
Modalità di visualizzazione Vota questo thread
Vota questo thread:

Distacco regolamento
Tu non può post nuovo thread
Tu non può inviare una risposta
Tu non può postare allegati
Tu non può modificare i tuoi post

BB codice è Su
Smilies sono Su
[IMG] codice Su
Codice HTML è Chiuso
Trackbacks sono Su
Pingbacks sono Su
Refbacks sono Su




Tutti gli orari sono GMT -4. La data di oggi è 10:42 PM.


Powered by: vBulletin, Copyright © 2000 - 2006, Jelsoft Enterprises Limited. Traduzioni Powered by .
vBCredits v1.4 Copyright © 2007 - 2008, PixelFX Studios
UNIX e Linux Forum Content Copyright © 1993-2009. Tutti i diritti Reserved.Ad di gestione da RedTyger

Contenuti pertinenti URL da vBSEO 3.2.0