Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'search-and-replace with sed' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
search-and-replace with sed
Authored by: hopthrisC on May 18, '04 04:18:32AM
replace

set txt to (do shell script "echo " & txt & "| sed -e 's|" & srch & "|" & repl & "|' ")

with

set txt to (do shell script "echo " & txt & "| sed -e 's|" & srch & "|" & repl & "|g' ")

(there's only one additional g near the end) and you can get rid of that repeat loop entirely. "g" stands for global and means sed should replace every occurance off the search string in the input line.

That will make the script much faster, too.

[ Reply to This | # ]