sed 's/$wfind/$wreplace/g' ~/file.txt > ~/file.txt
A couple gotchas. You are reading and modifying file.txt at the same time. "No bueno!"
Quotes is always something to be mindful due to the shell.
sed "s/$wfind/$wreplace/g" ~/file.txt > tmp.file && mv tmp.file ~/file.txt
want to remove somthing from a file eg. #deb http:// i want to remove the # from this line how can i do this?
Choose!
Remove every first instance of # in every line in file.db
sed 's/#//' file.db
Remove # out any line that starts with it, followed by the characters deb
sed 's/^#deb/deb/' file.db
Remove # out the beginning of line 3
sed '3 s/^#//' file.db
Aia
Nearly a Posting Maven
2,394 posts since Dec 2006
Reputation Points: 2,224
Solved Threads: 220
Skill Endorsements: 14