0
votes
1answer
41 views

How can I do a recursive find and replace from the command shell?

Using a shell like bash or zshell, how can I do a recursive 'find and replace'? In other words, I want to replace every occurrence of '/path/to/folder' with '/other/dir' in all files in this directory ...
1
vote
1answer
4k views

Multi-Line Sed Replace

Consider the following text (incidentally, part of a MySQL dump): CREATE TABLE `table` ( `id` int(10) NOT NULL auto_increment, `name` varchar(100) NOT NULL default '', `description` text NOT ...
3
votes
2answers
1k views

Multiple search and replace actions in one large text file

I have a big text file (about 2GB). I want to do five search and replace actions on the same file, and would like to do this in one command. Normally I use vim, open the file, do one replace action, ...
1
vote
1answer
67 views

Matching html paragraphs with at least one word in all caps

Using regex or anything, I need to match any paragraph which contains at least one all caps word. Then transform it into a header and capitalise all the content of the title. In the example below, ...
3
votes
3answers
722 views

Substituting a multi-line pattern in an HTML file

I have a series of HTML files that contain two lines like this: <body> <h1>Title</h1><p> <a href="url">Description</a><br> I want to replace this text with ...
0
votes
1answer
474 views

Multi-line find and replace across multiple files on linux

I have: Old Google analytics tracking code oldcode.txt New Google analytics tracking code newcode.txt 100+ html files *.html in one directory Is it possible to replace former with latter in all ...
1
vote
1answer
287 views

Replace a regular expression within vim with an output produced by a console command with the expression as its argument?

let's say I have a file with the following content: This is a _file_ which has some _special_ keywords, that I would _like_ to replace. I can do a search and replace of the speical keywords ...
1
vote
1answer
48 views

Automatic replacement of expressions

Maybe this can be achieved through (extended) regular expressions, but I really don't know if or how. There seems to be a way to access "things that are found" by using $1, $2, … but I have no idea ...
2
votes
3answers
100 views

using vims pattern-multi-items {n} to match the 5th space in a line

With this entry from our crontab 1 3 1 * * find /var/log/tomcat/* -mtime +61 -type f -delete I want to match the 5th space char so I can separate the command part from the time field part. Cron ...
0
votes
2answers
78 views

Search and replace text and everything that follows in the same line

How can I search for a certain string in multiple files (with a given extension) in a directory and replace everything afterwards (including the search string) with a blank string? Example I'm ...
0
votes
2answers
362 views

search, remove duplicates and marge to one file

What is going to be my best way to search and remove duplicate's from over 50GBs worth of text files and merge them into one? I figure a GUI app will just hang so I need a CLI style with threading ...
1
vote
1answer
1k views

Replace a block of numbers in sed

I've been fiddling with this for a while now and can't seem to figure it out. What I'm trying to do is replace all numbers in a file with a single #. Sounds simple, and it should be, but I can't get ...
0
votes
1answer
506 views

editing PDFs (find and replace '&nbsp;')

What method/program could I use to perform a find and replace to turn '&nbsp;' into ' ' in a PDF file? I can use either linux or windows solution. EDIT: The addon for OpenOffice Draw to access ...
5
votes
2answers
2k views

how to do a vim search inverse search for all lines with out text

with grep I can do a grep -v "my search" to get all the lines with out "my search" with sed I can sed '/baz/!s/foo/bar/g' to find replace text on lines with out baz Is there a way to do the same ...
1
vote
1answer
483 views

Linux shell script: copy a (text) file and replace a token with a path

I need to create a text file where parts of it should be replaced by any arbitrary path. I wanted to do that by copying a template file and then replace a special pattern, e.g. ${MY_PATH} with the ...
-1
votes
1answer
375 views

Linux “rpl” command doesn't replace text

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: ...
3
votes
1answer
441 views

Linux: Find all occurrences of “string1” in files under a directory and replace them with “string2”

In linux, what's a good way to find all occurrences of "string1" in files under a directory and replace them with "string2"?
0
votes
2answers
273 views

Using sed to replace a *large* number of variables in a file

I have a large number of log files, on a linux box, I need to cleanse sensitive data from before sending to a third party. I have used the below script on previous occasions to perform this task, and ...
2
votes
2answers
8k views

Using sed to replace string with special characters in XML file

I am having difficulty getting sed to replace a string of text in an XML file, despite the fact that I have no trouble using grep to find that same string. Since the new string and old string to be ...
1
vote
2answers
87 views

Trying to cleanse log files on a Linux machine, currently using sed

I have a large amount of log files that I need to remove sensitive data from. The sensitive data is provided to me in a text file and is prone to change. I had hoped to do the equivalent of this: ...
0
votes
2answers
2k views

recursively replace every instance of a word in a directory from linux command line

I have a directory with several subdirectories that all contain text files. In these text files, there is a certain word that occurs over and over again, and I want to replace every instance. My ...
2
votes
1answer
1k views

grep + sed for find & replace fun!

I have a dev copy of a website set up that has quite a few hardcoded references to its live counterpart. I would like to replace all occurrences of "www." with "dev." in all files. I think I can use ...
2
votes
4answers
1k views

How do I do a string replace in all PHP files recursively on Linux?

I have a function name that was misspelled, and I want to change it. The function is called in many places of the project. How can I do this with a Linux command on SUSE?