Pasting your sorted files in your question, or giving an insight on how you sorted the files would be helpful.
In most cases the answer of @ChrisDown should work. My answer solves a problem that beginners might sometimes face.
sort file1.txt
prints the sorted output, but does NOT change the original file. So when you use sort, it is important to check whether the files are actually sorted.
It will be clear in the output shown below.
┌──(user㉿user)-[~/Desktop/abc]
└─$ sort no1.txt
26
67
789
98
┌──(user㉿user)-[~/Desktop/abc]
└─$ cat no1.txt
789
67
98
26
Here sort gives us the sorted contents of the file, but when I see the contents of the file, it shows the original file itself.
(Kindly refer to the end of this answer for the original txt files.)
One way in which you can pass on the sorted file to comm is shown below.
- Sort each file and pipe it to cat to create a new file with the sorted contents.
- Pass on the new files to comm.
┌──(user㉿user)-[~/Desktop/abc]
└─$ cat int1.txt
26
67
789
98
┌──(user㉿user)-[~/Desktop/abc]
└─$ sort no2.txt | cat > int2.txt
┌──(user㉿user)-[~/Desktop/abc]
└─$ comm int1.txt int2.txt
26
45
67
789
88
98
Text files:
no1.txt
789
67
98
26
no2.txt
789
67
45
88
sort
utility works like this as well.