shell - For every string in file1.txt check if it exists in file2.txt then do something -
i got 2 txt file, file1.txt , file2.txt. both of them have 1 single string each line. strings in file1.txt uniqe (no duplication), strings in file2.txt. files have different numbers of strings.
file1.txt file2.txt fff aaa ggg bbb zzz ccc zzz
i'd compare files, every string in file1.txt, if exists in file2.txt it's ok. if not, write string in file (file3.txt)
in example, file3.txt be:
file3.txt fff ggg
i'd utilize command shell, doing like:
cat file1.txt | while read a; on file2.txt ...
but not compulsory.
see man page grep, -f option.
grep -vf file2.txt file1.txt
string shell
No comments:
Post a Comment