bash while read how to remove \n character

Hi,

I've made a script to grep a file

for i in `cat filename.txt`
do
    strings ./binfile | grep "$i" 2>&1 > /dev/null
done

this works fine as long as in filename.txt i don't have any entries with spaces. But in my case i want to grep something with spaces like "lala tata"
and the above script greps for lala and then with tata.

When I use while read i have the same problem.
any ideas anyone??

thanks,
papasj

You have to set IFS to a newline character before executing your loop:

IFS="
"
for ...; do ...; done

Or, for a nicer single line version:

IFS=$'\n'
for ...; do ...; done

thanks, it works fine after the IFS

also " tr " could delete END OF THE LINE , try

echo abcd | tr -d '\n'