I am working to create a script which will take a string as an argument and replace recursively in a directory. The simple case (a single word) is admirably handled by the following find and replace script:
grep -rl $1 . | xargs sed -i .backup -e "s/$1/$2/g"
But here things get a bit more tricky. The string I am trying to deal with...
I'm faced with the task of find and replacing multiple include files with the include file's content.
Just wondering if I'd be quicker copy / pasting than writing a bit of code to do so, or if there's a tool out there that could do this for me?
Pretty sure its a common need. I'm on Windoze btw. Any suggestions welcome.
Just to clarif...
How can you remove one line which contains the word SID in many files?
I wondering between sed and tr. However, neither of them seem to work for the purpose.
I also would like to have some flexibility because of the following reason.
The problem is actually slightly more challenging. I need to remove also one line after the match in so...
Using Vim, I'd like to be able to replace preVARIABLETEXTpost with VARIABLETEXT in a single command. The reason is that pre and post might exist elsewhere in the file, and VARIABLETEXT changes.
Something like:
:%s/preGRABTEXTpost/GRABTEXT/g
Essentially I'm trying to strip pre and post when it exists with some text between them on ...
I have text file:
gvim file.txt
In UNIX you can type this at any command prompt. If you are running Microsoft
Windows, open an MS-DOS prompt window and enter the command.
In either case, Vim starts editing a file called file.txt. Because this
is a new file, you get a blank window. This is what your screen will look
like:
...
hi
i want to find and replace functionality in contentEditable div.i want to add one toolbar in which one find and replace button placed. when one press this button then one popup window open and ask for keyword to search when keyword is given then it will find only in given div id not whole document and highlight it.
if any body know ab...
In eclipse, is it possible to use the matched search string as part of the replace string when performing a regular expression search and replace?
Basically, I want to replace all occurrences of
variableName.someMethod()
with:
((TypeName)variableName.someMethod())
Where variableName can be any variable name at all.
In sed I could...
I'm using rake to create a Table of contents from a bunch of static HTML files.
The question is how do I insert it into all files from within rake?
I have a <ul id="toc"> in each file to aim for. The entire content of that I want to replace.
I was thinking about using Nokogiri or similar to parse the document and replace the DOM node...
Example bad:
#main {
padding:0;
margin: 10px auto;
}
Example good:
#main {padding:0;margin:10px auto;}
I have a ton of CSS rules that are taking up too many lines. And I cannot figure out the :%s/ commands to use.
...
C# Need to locate web addresses using REGEX is that possible?
Basically I need to parse a string prior to loading it into a WebBrowser
myString = "this is an example string http://www.google.com , and I need to make the link clickable";
webBrow.DocumentText = myString;
Basically what I want to happen is a replace of the web address ...
I'm looking for a way to write a search and replace method using W3C DOM to update a tree. I've thought about doing a breadth-first search as below, but can't think of how to do the in place replacement?
import org.w3c.dom.Node;
private Element tree;
public void searchReplace(Node x, Node y){
Queue<Node> q = new LinkedList<Node>(...
I have some 150 files and in them I want to remove this following code:
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="/height.js"></SCRIPT>
What I'm doing is:
sed -e 's/<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="/height.js"></SCRIPT>/ /' file_names
This doesn't seem to work.
I want to remove this script...
i want to replace certain strings with another one in a text File( ex: \nH with ,H) .Is there any way to that using php?
...
How to replace \n from a line using sed command?
...
Let us say if I have a hash like this:
$data = {
'key1' => {
'key2' => 'value1'
},
'key3' => {
'key4' => {
'key5' => 'value2'
}
},
};
Now, how can I replace the the key 'key5' with some other key name say 'key6'?...
I'm trying to allow a user (using Wordpress) to insert a jquery slideshow gallery (http://www.queness.com/resources/html/slideshow/jquery-slideshow.html) based on a faux tag. For example:
[slideshow]
<img src="url" /><br />
<img src="url" />
[!slideshow]
Would produce something similar to
<div id="gallery">
<a href="#"><...
I need to convert expressions of the form:
return *;
into:
return filter(*);
It seems simple enough to express it with wildcards, however, in visual studio's search & replace dailog, there's no way to associate the first asterisk with the second one. I suppose a regex can do this quite easily, however I know very little about regex...
I am not very good at regex, but I need to convert the following example from this
<li>Creations by Carol - www.driedfloralcreations.com</li>
to
<li>Creations by Carol - <a href="http://www.driedfloralcreations.com" rel="external">www.driedfloralcreations.com</a></li>
...
How to I find and replace every occurrence of:
subdomainA.example.com
with
subdomainB.example.com
in every text file under the /home/www/ directory tree (recursive find/replace).
...
Using just grep and sed, how do I replace all occurrences of:
a.example.com
with
b.example.com
within a text file under the /home/user/ directory tree recursively finding and replacing all occurrences in all files in sub-directories as well.
...