Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • @inderpreet99 The lower case -u argument does actually take a parameter of a number as long as it is not followed by a space. The advantage of the way I had it before is that it will work with or without a value, so you could use something in that sub command routine that returned not output. Upper case '-U' on the other hand requires an argument. Commented Aug 27, 2013 at 21:46
  • be careful, grep -f is O(N^2) I believe: stackoverflow.com/questions/4780203/… Commented Oct 16, 2015 at 17:33
  • To account for the sort problem, you could use process substitution in the command to process each file before the grep as needed. Example: grep -F -x -v -f <(sort fileB) <(sort fileA) Commented Oct 4, 2017 at 15:22
  • @TonyCesaro That would work if your data set is not order specific and duplicates don't need to be taken into account. The advantage of using diff is that position in the file gets taken into account. Commented Oct 5, 2017 at 6:06
  • 1
    The options can be collapsed together to get a shorter version: grep -Fxvf fileB fileA. Commented Oct 13, 2020 at 13:39