[ILUG] Find & replace script (?)

Lars Hecking lhecking at nmrc.ucc.ie
Mon Aug 23 12:57:39 IST 1999


kevin lyda writes:
> Lars Hecking spoke thusly:
> >$ for i in `find /foo/bar -name '*.html' -print` ; do mv ${i} ${i}.bak ; \
> >  sed 's,tag,replacement,g' ${i}.bak >${i} ; rm -f ${i}.bak ; done
> >
> > If the tag is different in different files, it gets more complicated,
> > and others might suggest perl ...
> 
> i think sed's the way to go and sent an email privately with much the
> same suggestion.  one point though is the 10,000 to 35,000 files.
> won't the find command blow away the command line limit length?
> i split it up - find > file.list; cat file.list | xargs -n 1 script

 Generally, I agree, but I think that GNU find and bash should
 cope quite well. Assuming the system in question is running Linux :)





More information about the ILUG mailing list