search and replace the content

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting search and replace the content
# 1  
Old 10-06-2009
search and replace the content

Hi All,sorry for inconvience....please find the attachement for my question i am unable to paste the question here....please help me in slving thisthanksk.k

Last edited by G.K.K; 10-06-2009 at 03:05 AM.. Reason: unable to paste the content
# 2  
Old 10-06-2009
You could have given a better explanation about your requirement !

If i got your requirement properly, then use the following.

grep '"' temp_search.txt
if [ $? -eq 0 ];then
mv temp_search.txt initial.txt

# 3  
Old 10-06-2009
sorry missed the content...

Hi All,i have a file temp_search.txt i want to place this file content in to the original file initial.txt when it found the pattern
# 4  
Old 10-06-2009
Do you mean replace the pattern with the file contents? Add the contents after the line with the pattern? Replace the line with file contents? It isn't clear what you mean.
# 5  
Old 10-06-2009


while read initial_line
        ret=`echo $initial_line | grep '<selectValue'`
        if [ -z "$ret" ]
        echo $initial_line
                p=`echo $initial_line | awk -F'>' '{print ($1)}'`
                echo -n $p
                cat temp_search.txt
done < initial.txt

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Nested search in a file and replace the inner search

Hi Team, I am new to unix, please help me in this. I have a file named properties. The content of the file is : ##Mobile props east.url= west.url= south.url= (2 Replies)
Discussion started by: tolearn
2 Replies

2. Shell Programming and Scripting

Help with replace all the content within ()

Hi, Below is my input file : AAAG(12) TC(14) AACCCT(66) AACCCT(30) AACCCT(18) AACCCT(48) TCTG(12) TCTG(20) TCTG(16) AC(12) AC(12) TCTG(16) TCTG(12) AC(12) AC(12) AC(12) AC(26) AC(14) AGTG(12) AC(24) AGTG(12) TCC(12) Desired output : AAAG TC AACCCT AACCCT AACCCT AACCCT TCTG TCTG... (4 Replies)
Discussion started by: perl_beginner
4 Replies

3. Shell Programming and Scripting

Search & Replace content of files using gsub in awk

Hi,I have 2 files master.txt & reference.txt as shown below & i require o/p as mentioned in file 3 using awk but content is not replacing properlymaster.txt:... (15 Replies)
Discussion started by: siramitsharma
15 Replies

4. Shell Programming and Scripting

Search & replace content using awk/gsub

Hi, I have two files master.txt & reference.txt. Sample below Master.txt 2372,MTS,AP 919848001104,Airtel,DL 0819,MTS,MUM 919849788001,Airtel,AP 1430,Aircel MP,20 Reference.txt 2372,919848701430,46467 919848002372,2372,47195 2372,919849788001,59027 0819,028803,1 0819,029801,1... (2 Replies)
Discussion started by: siramitsharma
2 Replies

5. Shell Programming and Scripting

Sed: replace content from file with the content from file

Hi, I am having trouble while using 'sed' with reading files. Please help. I have 3 files. File A, file B and file C. I want to find content of file B in file A and replace it by content in file C. Thanks a lot!! Here is a sample of my question. e.g. (file A: a.txt; file B: b.txt; file... (3 Replies)
Discussion started by: dirkaulo
3 Replies

6. UNIX for Advanced & Expert Users

Search Parameter in first line and replace next line content

Hi, I need help. I have XML file as below &lt;a n=&quot;infoLevel&quot;&gt; &lt;v s=&quot;true&quot;/&gt; &lt;/a&gt; &lt;a n=&quot;localAddr&quot;&gt; &lt;v s=&quot;;/&gt; &lt;/a&gt; &lt;a n=&quot;ListenPort&quot;&gt; &lt;v s=&quot;21111&quot;/&gt; &lt;/a&gt; I need to find variable "ListenPort" in line and then replace... (4 Replies)
Discussion started by: rdtrivedi
4 Replies

7. Shell Programming and Scripting

awk - replace number of string length from search and replace for a serialized array

Hello, I really would appreciate some help with a bash script for some string manipulation on an SQL dump: I'd like to be able to rename "sites/WHATEVER/files" to "sites/SOMETHINGELSE/files" within the sql dump. This is quite easy with sed: sed -e... (1 Reply)
Discussion started by: otrotipo
1 Replies

8. Shell Programming and Scripting

Perl search and replace file content.

I am not sure if this is doable. I am trying to open and print the content of the file by replacing all instances fo perl to PERL . This is my code but it is giving me the number count instead of the actual lines with changes. open (PERLHISTORY, 'sample.txt') or die "The file sample.txt could... (3 Replies)
Discussion started by: jxh461
3 Replies

9. UNIX for Advanced & Expert Users

Search files with specfic extention and later search content

Hi, I would appriciate if somebody can help me figure out how to search for all the *.xml file under a specific directory and subdirectroies (/home/username) and later search of content "<start>" inside the xml file returned by search. -Lovin.V (2 Replies)
Discussion started by: lovi_v
2 Replies

10. Shell Programming and Scripting

Perl: Search for string on line then search and replace text

Hi All, I have a file that I need to be able to find a pattern match on a line, search that line for a text pattern, and replace that text. An example of 4 lines in my file is: 1. MatchText_randomNumberOfText moreData ReplaceMe moreData 2. MatchText_randomNumberOfText moreData moreData... (4 Replies)
Discussion started by: Crypto
4 Replies
Login or Register to Ask a Question