for term in `cat stopwords`; do sed -i 's/\<$term\>//g' spam.txt ;done
Given stopwords contains a word per line and spam.txt is plain text file, I just need to replace exact matches of stopwords. Does not behave as I expect ...
Note there are words like doesn't
, couldn't
in both the files.
Are you sure you want to run sed in for loop? I would use sed script-file.
TMPFILE=mktemp
for WORD in $(cat stopwords); do echo 's/'$WORD'//g' >> $TMPFILE; done
sed -f $TMPFILE spam.txt
rm -f $TMPFILE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With