comm -2 -3 <(sort A.txt) <(sort B.txt)
should do what you want, if I understand you correctly.
Edit: in fact, you commneed files that need to be sorted in lexicographic order, so you do not want -nin your command sort:
$ cat A.txt
1
4
112
$ cat B.txt
1
112
$ comm -2 -3 <(sort -n B.txt) <(sort -n B.txt)
4
comm: file 1 is not in sorted order
112
$ comm -2 -3 <(sort A.txt) <(sort B.txt)
4
source
share