![]() |
|
|
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 |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Cerca in questo Thread | Rate Thread | Modalità di visualizzazione |
|
|
|
||||
|
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. |
|
||||
|
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:
|
|
|||||
|
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
|
![]() |
| Segnalibri |
| Thread Tools | Cerca in questo Thread |
| Modalità di visualizzazione | Vota questo thread |
|
|