This works fine. Firstly please place code within
[code][/code] tags.
My contents of rogue.txt are the same as yours.
My contents of test.txt is the word bash.
The script as I've copied it, but note that I've indented as well as put in
#!/bin/sh, I called it sear.sh:
Code:
#!/bin/sh
while read line
do
if [ $(grep -c $line rogue.txt) -gt 0 ]
then
echo "word in rogue.txt"
else
echo "word not in rogue.txt"
fi
done <test.txt
The output:
Code:
~/testcode$ ./sear.sh
word in rogue.txt
~/testcode$
If you're not seeing this, then I wonder if there are other parts of your script which you're not showing; can you elaborate and also check what shell you're running?
Another suggestion is to put the following near the top of your script to enable debugging output:
HOWEVER, this all assumes you're using BASH.