#!/bin/bash
while read line; do
grep "$line" file1.txt
if [ $? -eq 1 ]; then
echo "$line" >> f2.txt
fi
done < f3.txt
There are a bunch of errors in your code.
- structure of if is wrong
- there is a space missing before the closing bracked
- I believe the $status thing you are using is wrong. You check the return status of a command using $?