Register
It is currently Fri Oct 31, 2014 2:23 am

Need help improving recursive search-replace script


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Fri May 22, 2009 10:08 am   

Joined: Fri May 22, 2009 9:58 am
Posts: 2
#!/bin/bash
TARGET="foo.php";
find -iname $TARGET -exec sh -cC '
sed 's/RreplaceMe/IGotReplaced/' "$fname1" > "$fname".new
' {} {} \;

find -iname $TARGET -exec rm {} \;

find . -type f -print0 | xargs -0 rename 's/.php.new/.php/'


Top
 Profile  
 PostPosted: Fri May 22, 2009 10:16 am   

Joined: Fri May 22, 2009 9:58 am
Posts: 2
ERRRGhhhhhh... don't do that; do this. :

#!/bin/bash
find -iname foo.php -exec sh -cC 'sed 's/ReplaceMe/IgotReplaced/' "$1" > "$1".new
' {} {} \;

find -iname foo.php -exec rm {} \;

find . -type f -print0 | xargs -0 rename 's/.php.new/.php/'


######THIS SCRIPT IS HORRIBLE. GOT ANY BETTER IDEAS?######


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP