Having tried tail for deleting the first two lines of a file, I wanted to try grep to subtract the contents of one file from another one’s. The suggestion was:
grep -vf smallfile bigfile
but it didn’t work. However, the following worked
grep -v -x -f smallfile bigfile
I’d like to know why, man doesn’t give me any clue. I’m using bash on openSUSE 12.3
wolfi, I saw that, I read the man. It just doesn’t make sense - it should work without “-x” !!! The first three lines are identical and the first file has only three lines. Why is the use of “-x” necessary ???
It didn’t work without ‘-x’ in the sense that it didn’t subtract the common lines and it didn’t do anything at all. If I add ‘-x’ it subtracts the common content and displays the difference.
wolfi323 wrote:
> It works fine here with a test case:
>
> Code:
> --------------------
> # cat file1
> Hello
> Test
> # cat file2
> Hello
> Test
> It works?
> # grep -vf file file2
> It works?
>
> --------------------
That must be magic, then unless ‘file’ happens to contain the same
content as ‘file1’
You’re supposed to cut and paste text in code quotes, not tell us
stories!