# removes lines that exist in file2 from file1 awk 'NR==FNR{a[$0]++;next} !a[$0]' file2.txt file1.txt > output.txt