ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I'm not a new Linux user, but it's only recently that I've been working on using this OS exclusively. That being said, I'm more familiar with using X as my workplace, but am familiar enough with command line usage to use it if a GUI option isn't available.
Anyway, I run a website and do the vast vast majority of my coding direct, instead of a web editor. In windows, I had a program called ReplaceEm that I could copy and paste a bunch of code and then the stuff I'd like it to be replaced with and it would go through various files, changing every instance of that string. It's really handy.
I checked around the forums and found a number of perl answers to questions fairly similar to that, but they all involved single line replacement, where my applications are more of multi-line instances. Maybe there's just a carriage return text that I don't know that I could use in-line with the perl solutions, but I'm not sure.
Do you know of a multi-line text replacer progam? Preferably GUI, but not entirely necessary.
sed 's/text to remove/text to replace/g' files.html
I think the OP means his patterns span more than one line. However, sed can do multiple line matching but it's a bit convoluted and involves using (IIRC - not a facility I use very often!) the "join" operator to get extra lines into the pattern space. Have a google to find a sed tutorial online (or make your patterns single line!).
I was going through Google looking for some good sed tutorials, only to find another program, called rpl, that has some pretty easy multi-line replace functionality. You just add an \n in the old string or new string to be interpreted as a newline. Then it turns out that it's in Debian Stable, and that's what I'm using.
So, anyone who reads this later, that may be an easier way to go about working on it. Especially if you're even slightly familiar with C, since that's the newline code in C. I've yet to find a GUI app using this (maybe I'll make one), but it's still none-the-less very handy.