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 8:40

PROTIP: find works recursively.

Name: Anonymous 2009-06-23 8:46

>>2
But there are no subdirectories in that folder!

Name: Anonymous 2009-06-23 8:51

why not just use s/come(s)? in/get\1 out/g?
works for me in perl

Name: Anonymous 2009-06-23 9:26

>>4
EXPERT SEDDER

Name: Anonymous 2009-06-23 9:28

>>1
because you touch yourself at night

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'

Name: Anonymous 2009-06-23 10:59

>>7
WOW COOL!!

Name: Anonymous 2009-06-23 15:13

>>7
How wasteful.  Do you not have a POSIX-compliant find?

Name: ​​​​​​​​​​ 2010-10-21 20:58

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