I have few wordlist files which is based on word per line.
Now, i want to generate new file, that should be:
compared first and second file and putting words from second file, that are not found in first, putting them in third file.
File_1
word1
word2
word3
word4
word5
File_2
word1
word3
word5
word7
word9
I tried few things:
cat file.1 file.2 | sort -n | uniq -u | cat > file.3
But i get:
File_3
word2
word4
word7
word9
Also i tried:
cat file.1 file.2 | sort -n | uniq -d | cat > file.3
but again I get:
File_3
word1
word3
word5
I tried also with ECHO
echo $(cat file.{1,2} | sort -n | uniq -u) > file.3
But i get same words, and what is worst it prints all at one line.
The final File_3 should contain:
word7
word9
Beacause these words are not found in first file.
Any idea how to accomplish this?
If your file is not big you can basically cat first file twice:
but this is expensive for big files.
or using grep you can achieve this (thanks to @tripleee):