Reputation: 55
The file1 store Sentence want to grep,Here 's content file1
.|||anymore .
,|||arguments
,|||atheists
,|||be
,|||because the
.|||because the
The problem is it contain space in some sentence , and the target file2 contain the space too, how can I search all file2 content to know whether file2 has these sentence which in file1 or not
If found it output grep result to anther file(append) ,If no found output a file to keep it
Upvotes: 0
Views: 67
Reputation: 1770
Try this-
while IFS= read -r i; do #Reading the file line by line and saving lines in $i.
grep "$i" file2 >> output #Grepping the line in the second file and outputting.
done < file1
Your question needs to be edited to give some more details though.
Upvotes: 2