Take the 2-minute tour ×

Goal: create a file listing all lines not found in either file

OS: Mac OS X, using Terminal

Problem: lines contain accented characters (UTF-8) and comparison doesn't seem to work

I've used the following command for comparing both files:

comm -13 <(sort file1) <(sort file2) > file3

That command works fine except with lines in files containing accented characters. Would you have any solutions?

One non-optimal thing I've tried is to replace all accented characters with non-accented ones with sed -i but that didn't seem to work on one of my two files, so I assume one file is weirdly encoded (in fact, ü is displayed u¨ when opening the file in TextMate but correctly as ü in TextEdit – I had generated that file using find Photos/ -type f > list_photos.txt to scroll through all filenames which contain accented characters... maybe I should add another parametre to the find command in the first place?). Any thoughts about this as well?

Many thanks.


I manually created text files with accented characters. The comm command worked without requiring LC_ALL. So the issue must be with the output of filenames into a text file (find command).

Test file A:

Istanbul 001 Mosquée Süleymaniye.JPG
Istanbul 002 Mosquée Süleymaniye.JPG

Test file B:

Istanbul 001 Mosquée Süleymaniye.JPG
Istanbul 002 Mosquée Süleymaniye - Angle.JPG
Istanbul 003 Ville.JPG

Comparison produces expected results. But it's when I create automatically those files, I instead get Su¨leymaniye for instance in the text file. When I don't generate an output file, the terminal however shows me the correct word Süleymaniye.

Many, many thanks for looking into it. Much appreciated.

share|improve this question

1 Answer 1

You need to set the ENVIRONMENT for comm.


For example:

LC_COLLATE=C comm -13 <(sort file1) <(sort file2) > file3


share|improve this answer
Hmm thank you... I just tried and I still have the same issue :-/. –  seb Jun 15 at 0:29
Can you provide a few lines of the file(s) you're trying? –  l'L'l Jun 15 at 0:34
I updated the original post (at the end) because I couldn't format the comment here in a good way. Many thanks for looking into this, I really appreciate it. –  seb Jun 15 at 10:32

Your Answer


