This works fine. Firstly please place code within [code][/code]
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:
while read line
if [ $(grep -c $line rogue.txt) -gt 0 ]
echo "word in rogue.txt"
echo "word not in rogue.txt"
word in rogue.txt
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.