Tagged Questions
1
vote
2answers
256 views
How to find and replace files contents that match a pattern?
Suppose we have a folder named Project.
I would like find each file in the folder that contains the pattern &$
at the function call.
For example should replace:
AnyFunction(&$arg);
with
...
4
votes
2answers
161 views
Why does this add spaces? echo “x ax” | sed 's/x\s*/x /'
I want to find a x, and replace the 0 or more following spaces (\s*) with just a single space.
echo "x ax" | sed 's/x\s*/x /'
For some reason, instead of replacing the spaces with the single space, ...
4
votes
1answer
161 views
Emacs simple arithmetics in query replace
Is it possible to do the following in emacs:
Query replace all numbers in a region by the number +n, for example if you have:
12 and 7 are nice numbers
let n be 3, then it should transform to
15 ...
1
vote
4answers
335 views
Replace text between brackets
I'm using awk '{ gsub(/BAR|WIBBLE/, "FOO"); print }' to replace text in data like:
SOMETHING [BAR, WIBBLE]
SOMETHING [BAR]
This gives the desired result of:
SOMETHING [FOO, FOO]
SOMETHING [FOO]
...
2
votes
1answer
205 views
How to join vCards lines
vCard uses a special way to split long lines: At 75 characters, insert a DOS newline and a space. Joining therefore means to replace all occurrences of the sequence "CR, LF, space" with an empty ...
2
votes
2answers
508 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
1answer
839 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 ...