Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Video youtube
- https://youtu.be/iXtCtCXcgDk
- Codice AWK
- ---------------------------------------------------------
- BEGIN{FS=OFS=";"}
- {sub(/;$/,"")}
- NR==FNR{
- for (i=1;i<=NF;++i)
- for (j=1;j<=NF;++j)
- if (j!=i&&!b[$i,$j]++)
- a[$i,++c[$i]]=$j
- next
- }
- {
- delete b
- for (i=1;i<=NF;++i)
- ++b[$i]
- for (i=1;i<=NF;++i)
- for (j=1;j<=c[$i];++j)
- if (!b[a[$i,j]]++)
- $(NF+1)=a[$i,j]
- print
- }
- -----------------------------------------------------------------
- Come utilizzarlo:
- Andare al percorso dove è installato awk, assicurarsi che i 2 file di testo siano nella stessa cartella e poi digitare
- awk -f script.awk 2.txt 1.txt
- In pratica da questi due file di testo
- 1.txt
- UU;
- AA;BB;
- ZZ;KK;
- 2.txt
- CC;DD;BB;AA;
- LL;KK;
- GH;ZZ;SS;
- Si genera un terzo file di testo cosi formattato
- UU;
- AA;BB;CC;DD;
- ZZ;KK;LL;GH;SS;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement