![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| search and replace a specific text in text file? | santosham | UNIX for Dummies Questions & Answers | 4 | 06-25-2008 05:53 PM |
| How to search and replace text in same file | Vrgurav | Shell Programming and Scripting | 1 | 04-25-2008 06:20 AM |
| automating file search and replace text | ommatidia | Shell Programming and Scripting | 3 | 02-28-2008 04:40 PM |
| Perl: Search for string on line then search and replace text | Crypto | Shell Programming and Scripting | 4 | 01-04-2008 10:24 AM |
| appending string to text file based on search string | malaymaru | Shell Programming and Scripting | 1 | 06-09-2006 08:53 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
how can search a String in one text file and replace the whole line in another file
i am very new to UNIX
plz help me in this scenario i have two text files as below file1.txt name=Rajakumar. Discipline=Electronics and communication. Designation=software Engineer. file2.txt name=Kannan. Discipline=Mechanical. Designation=CADD Design Engineer. name=Ravi. Discipline=Metallurgy. Designation=Quality Analyst i want the output be like this in file2.txt name=Rajakumar. Discipline=Electronics and communication. Designation=software Engineer. name=Ravi. Discipline=Metallurgy. Designation=Quality Analyst i want to search for the string in one text file and search for the same in next file if it exist i want to repace the whole line with the line inwhich String exist in the first file as like the above files. please help me to solve this by using shell scripting And SED commands. Thanks in Advance, Last edited by kkraja; 08-06-2008 at 02:24 AM.. |
|
||||
|
How do you know which ones to replace?
i.e. file1.txt contains name=Rajakumar, which you have used to replace the first occurrence of name=Kannan, however for Discipline you have replaced the last occurrence. There is no way you can programme this unless there are clear rules to follow. |
![]() |
| Bookmarks |
| Tags |
| unix commands |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|