Mar 092010
Speedup sed search and replace
Answer:
If you have a very large file, sometimes you can speed up sed by using the following method:
Original method:
# sed 's/foo/bar/g' filename
Optimized method:
# sed '/foo/ s/foo/bar/g' filename
The second method is faster since substitution is only performed when the search string is found.