Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Why is this so slow?

Name: Anonymous 2009-06-23 8:36

I have this script;

#!/bin/sh

find . -type f -exec sed -i -e "s/comes in/gets out/g" {} \;
find . -type f -exec sed -i -e "s/come in/get out/g" {} \;


It takes about 30 seconds to run while a simple [code]sed 's/comes in/gets out/g' -i *[code] takes about two seconds. Why's that?

Name: Anonymous 2009-06-23 10:50

>>1
Because in the first find has to fork and execute sed once for every file, while the second has one sed instance for all the files.

find . -type f -print0|xargs -0 sed 's/come(s)? in/get\\1 out/g'

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List