The replace tag has no wiki summary.
0
votes
1answer
44 views
How to replace text after the cursor location in VIM
Suppose I have one line:
Linux is not_ Linux
My cursor lies on the _ mark and I want to replace the second Linux to Unix,how can I do that in vim?
2
votes
2answers
95 views
regex replace text in xml file within node from the command line
I have an XML file and I would like to replace everything that is between the open and closing tag within multiple instances of the g:gtin node with nothing.
Is this possible from the command line, ...
2
votes
3answers
105 views
Replace whole line in a file from command-line
I have a text file which has some contents similar to this:
# General information about the project.
project = u'Py6S'
copyright = u'2012, Robin Wilson'
# The version info for the project you're ...
2
votes
1answer
70 views
Replace using VIM, reuse part of the search pattern
I am working with VIm and trying to set up a search and replace command to do some replacements where I can re-use the regular expression that is part of my search string.
A simple example would be a ...
4
votes
1answer
117 views
Conditional search and replace on a line in vim?
Let' say I want to comment and uncomment a line.
I know I can
:s!^!//!
and then
:s!^//!!
Now what if I want this is a one-liner?
Basically, if a line starts with // then remove it, else add ...
3
votes
2answers
200 views
use awk to replace parentheses?
How can I use awk to replace the parentheses in these 2 scenarios?
Change empty parens to the word "None"
192.168.0.24,Up,()
Remove parens to only host.domain.com is left
...
5
votes
4answers
242 views
Vim :s replace first N < g occurrences on a line
In vim, I sometimes have occasion to replace the first few occurrences of a match on a line, but not every one like g would. e.g.:
a a a a a
to
b b b a a
I know I could use ...
7
votes
1answer
84 views
Case-preserving search and replace in vim?
In vim, I know I can search with or without case sensitivity. But if I want to search for a string in either upper or lower case, and replace it with a replacement of the same case, is that possible ...
1
vote
4answers
117 views
Using sed to convert newlines into spaces
Say I have a shell variable $string that holds some text with several newlines, e.g.:
string="this
is
a test"
I would like to convert this string into a new string new_string where all line breaks ...
6
votes
7answers
634 views
How can I “cat” a file and remove commented lines?
I'd like to know if there is a way that I could cat file like php.ini and remove all lines starting with ;
For example, if the file contained this:
; - Show all errors, except for notices
;
...
4
votes
2answers
142 views
Replacing identical NIC cards creates eth1 instead of using eth0 in Ubuntu
I changed out a NIC card that was the exact same make and model. The setup process for Ubuntu 11.04 was very seemless and easy so I figured it would be smart enough to setup up the replacement card. ...
2
votes
1answer
180 views
Replace complex string in several files
A hacker got into a web server and added this string (removed some characters for security purposes and added line breaks for readability) in all index.php files:
<?php
...
-2
votes
1answer
100 views
Linux “rpl” command doesn't replace text [closed]
I'm using rpl program in linux to replace date( with pdate( in some files.
But it says A Total of 0 matches replaced in 1 file searched.
while grep output for date( is:
...
5
votes
2answers
276 views
Replace string with contents of a file using sed
I have two different files:
File1
/home/user1/
/home/user2/bin
/home/user1/a/b/c
File2
<TEXT1>
<TEXT2>
I want to replace the <TEXT1> of File2 with the contents of File1 ...
3
votes
5answers
179 views
How to replace a list of placeholders in a text file?
I have a text (configuration) file, but the program that reads the file unfortunately doesn't allow using any kind of variables. So I'd like to use a preprocessor that replaces a set of placeholders ...