Inner join on two text files

bash, join, linux

Solution

Should not the file2 contain `LUA` at the end?

If yes, you can still use `join`:

join -t'|' -12 <(sort -t'|' -k2 file1) file2

Problem

Looking to perform an inner join on two different text files. Basically I'm looking for the inner join equivalent of the GNU join program. Does such a thing exist? If not, an `awk` or `sed` solution would be most helpful, but my first choice would be a Linux command. Here's an example of what I'm looking to do file 1: ``` 0|Alien Registration Card LUA|Checklist Update 1|Alien Registration Card LUA|Document App Plan 2|Alien Registration Card LUA|SA Application Nbr 3|Alien Registration Card LUA|tmp_preapp-DOB 0|App - CSCE Certificate LUA|Admit Type 1|App - CSCE Certificate LUA|Alias 1 2|App - CSCE Certificate LUA|Alias 2 3|App - CSCE Certificate LUA|Alias 3 4|App - CSCE Certificate LUA|Alias 4 ``` file 2: ``` Alien Registration Card LUA ``` Results: ``` 0|Alien Registration Card LUA|Checklist Update 1|Alien Registration Card LUA|Document App Plan 2|Alien Registration Card LUA|SA Application Nbr 3|Alien Registration Card LUA|tmp_preapp-DOB ```

Original source