tag:blogger.com,1999:blog-612171808890707553.post7329604438124899566..comments2023-10-13T21:22:58.121+09:00Comments on The Coding Slim Jim: mass replacement of text in filesAshley Smarthttp://www.blogger.com/profile/06991073477908020603noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-612171808890707553.post-12143952657449926172010-07-14T13:57:26.700+09:002010-07-14T13:57:26.700+09:00Thanks man. perl -pi is really much more convenien...Thanks man. perl -pi is really much more convenient for this a mass find and replace task. And I do use it too.<br /><br />However the post was because I have recently been working with tasks that locate one piece of information that is the key to taking a second action hence the paired sed regexps.<br /><br />I figured that applying it to simple mass search and replace task would make it easier to understand but I guess I wasn't clear about why I was using the sed's to do it in the first place.<br /><br />One of my recent usages of it was to login to a group servers with what should be the same web app running in all nodes, the inner sed builds a series of commands that find and md5's all the files in the web app on each node and dumps this to a file. Then I just diff the files and it tells me if any one of the apps are off and which file is wrong... And its all 1 (nightmare-ish) line on my local shell to boot.Ashley Smarthttps://www.blogger.com/profile/06991073477908020603noreply@blogger.comtag:blogger.com,1999:blog-612171808890707553.post-31318815088818869442010-07-13T12:10:15.847+09:002010-07-13T12:10:15.847+09:00Ash,
perl and xargs are your friends. The regexps...Ash,<br /><br />perl and xargs are your friends. The regexps are nicer too.<br /><br />perl -pi -e "s///g" file<br /><br />find ... | xargs perl -pi -e "s///g;s///g;s///g"<br /><br />edits the file in place, old version is put in file.bakPhil Mulhollandhttps://www.blogger.com/profile/02404517584047203456noreply@blogger.com