$ cat 1.txt 
321
123
1234
1452314124123
$ cat 2.txt 
321
1452314124123
1452314124123123123123
1234
3214

BSD grep:

$ grep -V
grep (BSD grep) 2.5.1-FreeBSD
$ grep -f 1.txt 2.txt -w
321
$ grep -f 2.txt 1.txt -w
321
1234
1452314124123

GNU grep:

$ grep -V
grep (GNU grep) 2.20
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Mike Haertel and others, see <http://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.
$ grep -f 1.txt 2.txt -w
321
1452314124123
1234
$ grep -f 2.txt 1.txt -w
321
1234
1452314124123
Comments
Write a Comment