Script for replacing text in a file based on list


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Script for replacing text in a file based on list
# 8  
Old 09-29-2010
Did you get the desired output on the screen? To update the file you have to do something like:
Code:
awk '....' file2 file1 > newfile
mv newfile file1

This User Gave Thanks to Franklin52 For This Post:
# 9  
Old 09-29-2010
Ahh, that I didn't look for. The file I am editing has over 5000 lines so I don't think that I would be able to catch it.
I will try piping like you recommend there and let you know.
Thanks!

---------- Post updated at 10:20 AM ---------- Previous update was at 10:18 AM ----------

That did it!
You are a lifesaver Franklin, that just saved me 2000 manual edits in vi. '
Thanks again!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Deletion of list of user based on a text file In LDAP UNIX server

Dear All, It would be really nice, if you could help me to write a script for deletion of list of user( more than 15000 users) stored in a file and sorted by email address( i need deletion of only a particular type of mail address). Is the any script to write and take the file as input and... (3 Replies)
Discussion started by: Chand
3 Replies

2. UNIX for Dummies Questions & Answers

Replacing stopwords based on a list

Dear all, I have Files with lines of text in them, I want to replace the stopwords in them with ",". I have create a file which contain the stopwords... I have been trying for last 3 hours but no success I have managed to replace one using "sed" and delete the line containing them using... (3 Replies)
Discussion started by: A-V
3 Replies

3. Shell Programming and Scripting

Replacing the text in a row based on certain condition

Hi All, I felt tough to frame my question. Any way find my below input. (.CSV file) SNo, City 1, Chennai 2, None 3, Delhi 4,None Note that I have many rows ans also other columns beside my City column. What I need is the below output. SNo, City 1, Chennai 2, Chennai_new 3, Delhi... (2 Replies)
Discussion started by: ks_reddy
2 Replies

4. UNIX for Dummies Questions & Answers

print multiple lines from text file based on pattern list

I have a text file with a list of items/patterns: ConsensusfromCGX_alldays_trimmedcollapsedfilteredreadscontiglist(229095contigs)contig12238 ConsensusfromCGX_alldays_trimmedcollapsedfilteredreadscontiglist(229095contigs)contig34624... (1 Reply)
Discussion started by: Oyster
1 Replies

5. Shell Programming and Scripting

Replacing headers based on a second file

I have a file with thousands of sequences that looks like this: I need to replace the headers using a second file Thus, I will end up having the following file: I am looking for an AWK script that I can easily plug in my current pipeline. Any help will be greatly appreciated! (6 Replies)
Discussion started by: Xterra
6 Replies

6. Shell Programming and Scripting

To run a script based on the value in text file

I have a Text file as shown below /* text file begins---------- ----------- Monthly files Loaded ------------- input_file record_count load_count reject_count ------------ ----------- ----------- ----------- 1_IN.txt 221935 221935 0 2_IN.txt 270668 270668 0 3_IN.TXT 231666 80370 151296... (7 Replies)
Discussion started by: nani1984
7 Replies

7. Shell Programming and Scripting

Delete block of text in one file based on list in another file

Hi all I currently use the following in shell. #!/bin/sh while read LINE do perl -i -ne "$/ = ''; print if !m'Using archive: ${LINE}'ms;" "datafile" done < "listfile" NOTE the single quote delimiters in the expression. It's highly likely the 'LINE' may very well have characters in it... (3 Replies)
Discussion started by: Festus Hagen
3 Replies

8. Shell Programming and Scripting

Replacing text based on replacement tables

Dear all, will be grateful for your advices.. The need is (i guess) simple for UNIX experts. Basically, there are replacement tables, which would be used to replace text strings in the data (large volumes..). An exmpl table (a "config file"): VIFIS1_1_PE1836 VIBRIO_FISCHERI VIPAR1_1_PE1662 ... (7 Replies)
Discussion started by: roussine
7 Replies

9. Shell Programming and Scripting

Bash script to delete folder based on text file information

I have been working on a script to list all the name's of a subfolder in a text file then edit that text file and then delete the subfolder base on the edited text file so far I have been able to do every thing I just talked about but can't figure out how to delete the subfolers base on a text file... (8 Replies)
Discussion started by: bone11409
8 Replies

10. Shell Programming and Scripting

replacing text in file1 with list from file2

I am trying to automate a process of searching through a set of files and replace all occurrences of a formatted text with the next item in the list of a second file. Basically i need to replace all instances of T????CLK???? with an IP address from a list in a second file. the second file is one IP... (9 Replies)
Discussion started by: dovetail
9 Replies
Login or Register to Ask a Question