Join
Zur Navigation springen
Zur Suche springen
Führt die Zeilen zweier sortierter Dateien anhand von Übereinstimmungen in einem gemeinsamen Feld zusammen.
root@zero:~# more name 1. karl 2. heinz 3. hans 4. otto root@zero:~# more tel 1. 1234 2. 4321 3. 222 4. 121212 root@zero:~# join name tel > telefonbuch root@zero:~# more telefonbuch 1. karl 1234 2. heinz 4321 3. hans 222 4. otto 121212
root@zero:~# join -t : /etc/passwd /etc/shadow .... daemon:x:1:1:daemon:/usr/sbin:/bin/sh:*:14181:0:99999:7::: bin:x:2:2:bin:/bin:/bin/sh:*:14181:0:99999:7::: sys:x:3:3:sys:/dev:/bin/sh:*:14181:0:99999:7::: sync:x:4:65534:sync:/bin:/bin/sync:*:14181:0:99999:7::: ...
join in dat1 nach Feld 3 und in dat2 nach Feld 2
thomas@lydia:~$ cat dat1 hugo:ps:1111 erwin:zw:2222 karl:sb:3333 rudi:kl:4444 thomas@lydia:~$ cat dat2 blau:1111:svn grün:2222:fcs gelb:3333:fch rot:4444:fck thomas@lydia:~$ join -t : -1 3 -2 2 dat1 dat2 1111:hugo:ps:blau:svn 2222:erwin:zw:grün:fcs 3333:karl:sb:gelb:fch 4444:rudi:kl:rot:fck