Replace text in match files


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Replace text in match files
# 1  
Old 12-16-2002
Replace text in match files

Hi all,

I want to replace text 'DEF' for those files containing text 'ABC'.

I can only locate the files containing text 'ABC', but I don't know how to replace the text 'ABC' with 'DEF'.

I use the following command to locate the files containing 'ABC'

find . -exec grep -l 'ABC' {} \;

But don't know how to replace it.

Thanks in advance.

Regards
Wilson
# 2  
Old 12-16-2002
sed 's/ABC/DEF/g' < inputfile > tmpfile
mv tmpfile inputfile
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Match value in two files and replace values in selected columns

The purpose is to check if values for column 3 and 4 in file1 match with column 1 in file2. If any value match do: 1) Replace values in file2 for column 2 and 3 using the information of file1 columns 5 and 6 2) Replace string ($1,1,5) and string ($1,6,5) in file2 with values of columns 7... (8 Replies)
Discussion started by: jiam912
8 Replies

2. Shell Programming and Scripting

2 files replace multiple occurances based on a match

Hi All, I need some help trying to achieve the below but everything I've tried has failed, I have 2 files which i'm trying to carry out a match based on the first column from file 1, take that value find it in file 2 if found replace it with the second column from File 1 Lookup File: File 1... (3 Replies)
Discussion started by: mutley2202
3 Replies

3. Shell Programming and Scripting

Bash to add portion of text to files in directory using numerical match

In the below bash I am trying to rename eachof the 3 text files in /home/cmccabe/Desktop/percent by matching the numerical portion of each file to lines 3,4, or 5 in /home/cmccabe/Desktop/analysis.txt. There will always be a match between the files. When a match is found each text file in... (2 Replies)
Discussion started by: cmccabe
2 Replies

4. Shell Programming and Scripting

Text match in two files

Trying to match the text from file1 to file2 and print what matches in a new file (match.txt) and what does not in another (missing.txt). awk -F'|' 'NR==FNR{c++;next};c > 0' flugent.txt IDT.txt > match.txt Thank you :). (8 Replies)
Discussion started by: cmccabe
8 Replies

5. UNIX for Dummies Questions & Answers

Match values/IDs from column and text files

Hello, I am trying to modify 2 files, to yield results in a 3rd file. File-1 is a 8-columned file, separted with tab. 1234:1 xyz1234 blah blah blah blah blah blah 1234:1 xyz1233 blah blah blah blah blah blah 1234:1 abc1234 blah blah blah blah blah blah n/a RRR0000 blah blah blah... (1 Reply)
Discussion started by: ad23
1 Replies

6. UNIX for Dummies Questions & Answers

Comparing two text files by a column and printing values that do not match

I have two text files where the first three columns are exactly the same. I want to compare the fourth column of the text files and if the values are different, print that row into a new output file. How do I go about doing that? File 1: 100 rs3794811 0.01 0.3434 100 rs8066551 0.01... (8 Replies)
Discussion started by: evelibertine
8 Replies

7. Shell Programming and Scripting

Find and add/replace text in text files

Hi. I would like to have experts help on below action. I have text files in which page nubmers exists in form like PAGE : 1 PAGE : 2 PAGE : 3 and so on there is other text too. I would like to know is it possible to check the last occurance of Page... (6 Replies)
Discussion started by: lodhi1978
6 Replies

8. Shell Programming and Scripting

match text from two files and write to a third file

Hi all I have two files X.txt and Y.txt. Both file contains same number of sentences. The content of X.txt is The filter described above may be combined. and the content of Y.txt is The filter describ+ed above may be combin+ed. Some of the words are separated with "+"... (2 Replies)
Discussion started by: my_Perl
2 Replies

9. Shell Programming and Scripting

Sed scripting, match text within line and replace

New to sed... Have a file foo.txt (below). Need to replace text on 2 lines, but can only feed sed the first few characters of each line (all lines are unique). So, in my example, I have put '$' in place of what I need to figure out how to feed the whole line. What I have thus far: sed -e... (6 Replies)
Discussion started by: boolean2222
6 Replies

10. Shell Programming and Scripting

Match and replace in different files

Hi, I want to replace the content in 3rd column in the first file by the line in the 2nd file (a list) if matches with 1st column of 2nd file. There are many 1st files in different directories: File1 172.27.1.15 222 I_J_Mar_Sci_34_27.pdf 172.27.28.1 489 Sci_Cult_71_60.pdf... (3 Replies)
Discussion started by: srsahu75
3 Replies
Login or Register to Ask a Question