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.
while read $line
grep $line $file2 > /dev/null
if [ $? -ne 0 ]; then
echo $line >> output.txt
done < $file1
while read line
NOT: while read $line
In the first you're declaring the variable which can be used as $line later in the script. In the latter you're attempting to use the variable and likely getting a null since you haven't previously declared it.
OMG. Well thank you. I was SO freaking close. Always has to be something dumb.
|All times are GMT -5. The time now is 08:24 PM.|