1
vote
0answers
13 views

Non case sensitive search case sensitive replace

How do I search/and replace like this using sed or another tool FOO => BAR Foo => Bar foo => bar That is: Look for foo regardless of case, and replace with the same case pattern. One ...
4
votes
2answers
50 views

shell script to replace a keyword in a file with the contents of another file

I'm to create a .sh to replace a specific keyword in a file using the contents of an other file. template.html contains a unique string "PLACEHOLDER" it must be replaced with the contents of file ...
2
votes
1answer
76 views

Use perl to do multi-line replacement [closed]

I have to do some replacements in many *.c files. I want to do the replacement like this: original: printf("This is a string! %d %d\n", 1, 2); result: print_record("This is a string! %d %d", 1, 2); ...
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, ...
2
votes
3answers
651 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
453 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
0answers
109 views

sed without regex

I am using GNU SED for find and replace functionality on large files(upto 2GB). Find and replace characters can contain any characters, hence I want find and replace parameters to be treated as plain ...
4
votes
2answers
904 views

sed: replace first occurance of a string in every line

Imagine I have a file like this: INSERT INTO table VALUES('1','<p><em>The lazy fox jumps again</em></p>bunch of other html<p><em>Is the lazy fox ...
1
vote
1answer
945 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 ...
1
vote
2answers
222 views

replace all names with an alternative using Stream editor (Sed)

I got this question on a task. Nothing works.. Can someone help me? Write a sed script that replace all names with an alternative, search for every words that: Start with a capital, Longer than ...
2
votes
1answer
2k views

How can I automate modifying key/value pairs in a shell script?

I often want to automate this sort of task in a shell script: if the line: SOMEKEY=SOMEVALUE exists in a file, then change it to SOMEKEY=SOMEOTHERVALUE otherwise, append the line ...
0
votes
2answers
270 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
7k 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
86 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: ...
1
vote
3answers
2k views

Using sed to replace text from a list of files from find

Given the following find command: find . | xargs grep 'userTools' -sl How can I use sed on the results of that command? output: ./file1.ext ./file2.ext ./file3.ext
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 ...