String replacement in multiple files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting String replacement in multiple files
# 1  
Old 02-17-2004
String replacement in multiple files

What is the most simple way to search multiple text files in multiple directories for a string then replace it with another string? I have about 300 files that I need to update and I'm just looking for alternatives rather than having to edit each one by hand.

Thanks in advance!
# 2  
Old 02-17-2004
I think I may have found the answer here:
https://www.unix.com/unix-for-dummies-questions-and-answers/9376-replace-text-match-files.html?s=

Any other thoughts on this?

Thanks.
# 3  
Old 02-17-2004
That sounds good to me ... pipe the output from the "find" command into a loop that performs perderabo's code on each file.

Thanks for searching first. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help on searching for a string on multiple files

Hi all, I am sure some gurus will find a better way of doing this. FYI, I've manually modified some of the data 'coz they are somewhat confidential, so there may be some typo errors. At the moment, I have 3 files that I am trying to search for. Sometime in the future, it may go beyond 3... (2 Replies)
Discussion started by: newbie_01
2 Replies

2. Shell Programming and Scripting

Script to find & replace a multiple lines string across multiple php files and subdirectories

Hey guys. I know pratically 0 about Linux, so could anyone please give me instructions on how to accomplish this ? The distro is RedHat 4.1.2 and i need to find and replace a multiple lines string in several php files across subdirectories. So lets say im at root/dir1/dir2/ , when i execute... (12 Replies)
Discussion started by: spfc_dmt
12 Replies

3. UNIX for Dummies Questions & Answers

replace string in multiple files

Hi, I'm new to Unix. My understanding of Unix and its command is very limited. I have about 1000 text files that have a word in it that I need to replace with a different word. e.g. a.txt has 1 line of txt: monday, tuesday, wednesday b.txt has 1 line of txt: monday, tuesday,... (5 Replies)
Discussion started by: millsy5
5 Replies

4. Shell Programming and Scripting

Changing a string in multiple files

New to scripting and unix. Would like to know how to change a string in a file. eg: From network=/usr/spool/progs/ to network=/spool/progs/ In multiple files. (4 Replies)
Discussion started by: smcraesun
4 Replies

5. UNIX for Dummies Questions & Answers

Joining string on multiple files

Hi guys, I am a forum (and a bit of a unix) newbie, and I currently have a tricky problem lying ahead of me. I have multiple files, and I am looking to join the files on the first column. Example: File 1 andy b 100 amy c 200 amy d 300 File 2 andy c 200 amy c 100 clyde o 50 ... (3 Replies)
Discussion started by: jdr0317
3 Replies

6. Shell Programming and Scripting

Multiple String with a number replacement and more..

Hello all, First of all, I could not made up a nice title what explains my problem in short,sorry for that already. I have the next file which contains the following, CREATE:ENTRY:\ DNAME,"referenceId=sondakika30,referenceId=User1,\ referenceId=Company,\ ... (2 Replies)
Discussion started by: sondakika
2 Replies

7. Shell Programming and Scripting

Replacing string in multiple files

Hi, I need to replace the string 'abcd' with 'xyz' in a file sample.xml This sample.xml is also present in the subdirectories of the current directory. Eg, If I am in /user/home/ the sample.xml if present in /user/home/ /user/home/folder1/ /user/home/folder2/... (3 Replies)
Discussion started by: arulanandsp
3 Replies

8. Shell Programming and Scripting

Multiple search string in multiple files using awk

Hi, filenames: contains name of list of files to search in. placelist contains the names of places to be searched in all files in "filenames" for i in $(<filenames) do egrep -f placelist $i if ] then echo $i fi done >> outputfile Output i am getting: (0 Replies)
Discussion started by: pinnacle
0 Replies

9. UNIX for Dummies Questions & Answers

last occurrence of a string across multiple files

Hello: Thank you for your help. (2 Replies)
Discussion started by: porphyrin
2 Replies

10. Shell Programming and Scripting

sed problem - replacement string should be same length as matching string.

Hi guys, I hope you can help me with my problem. I have a text file that contains lines like this: 78 ANGELO -809.05 79 ANGELO2 -5,000.06 I need to find all occurences of amounts that are negative and replace them with x's 78 ANGELO xxxxxxx 79... (4 Replies)
Discussion started by: amangeles
4 Replies
Login or Register to Ask a Question