Bash - find something in one file and if it doesn't exist in the second file print.
I'm trying to compare two files. I want to grab the first line in the first file and check second file to see if it exists. If it does not exist in second file then print. And so on for every line in file1.
Right now i don't get any output stuck into my output file. I'm sure this is easy and i've just stared at it too long.
#!/bin/bash
file1=/home/user/Documents/file1.txt
file2=/home/user/Documents/file2.txt
while read $line
do
grep $line $file2 > /dev/null
if [ $? -ne 0 ]; then
echo $line >> output.txt
fi
done < $file1
|