Sponsored Content
Top Forums UNIX for Dummies Questions & Answers how can search a String in one text file and replace the whole line in another file Post 302222067 by kkraja on Wednesday 6th of August 2008 01:45:12 AM
Old 08-06-2008
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 03:24 AM..
 

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

replace (sed?) a single line/string in file with multiple lines (string) from another file??

Can someone tell me how I can do this? e.g: Say file1.txt contains: today is monday the 22 of NOVEMBER 2010 and file2.txt contains: the 11th month of How do i replace the word NOVEMBER with (5 Replies)
Discussion started by: tuathan
5 Replies

3. Shell Programming and Scripting

Optimised way for search & replace a value on one line in a very huge file (File Size is 24 GB).

Hi Experts, I had to edit (a particular value) in header line of a very huge file so for that i wanted to search & replace a particular value on a file which was of 24 GB in Size. I managed to do it but it took long time to complete. Can anyone please tell me how can we do it in a optimised... (7 Replies)
Discussion started by: manishkomar007
7 Replies

4. Shell Programming and Scripting

Search and replace from file in awk using a 16 bit text file

Hello, Some time ago a helpful awk file was provided on the forum which I give below: NR==FNR{A=$0;next}{for(j in A){split(A,P,"=");for(i=1;i<=NF;i++){if($i==P){$i=P}}}}1 While it works beautifully on English and Latin characters i.e. within the ASCII range of 127, the moment a character beyond... (6 Replies)
Discussion started by: gimley
6 Replies

5. Shell Programming and Scripting

Search a string in a text file and add another string at the particular position of a line

I am having a text file which is having more than 200 lines. EX: 001010122 12000 BIB 12000 11200 1200003 001010122 2000 AND 12000 11200 1200003 001010122 12000 KVB 12000 11200 1200003 In the above file i want to search for string KVB and add/replace... (1 Reply)
Discussion started by: suryanarayana
1 Replies

6. Shell Programming and Scripting

Search a string in a text file and add another string at the end of line

Dear All I am having a text file which is having more than 200 lines. EX: 001010122 12000 BIB 12000 11200 1200003 001010122 2000 AND 12000 11200 1200003 001010122 12000 KVB 12000 11200 1200003 In the above file i want to search for string KVB... (5 Replies)
Discussion started by: suryanarayana
5 Replies

7. Shell Programming and Scripting

Replace and add line in file with line in another file based on matching string

Hi, I want to achieve something similar to what described in another post: The difference is I want to add the line if the pattern is not found. File 1: A123, valueA, valueB B234, valueA, valueB C345, valueA, valueB D456, valueA, valueB E567, valueA, valueB F678, valueA, valueB ... (11 Replies)
Discussion started by: jyu3
11 Replies

8. Shell Programming and Scripting

Search string within a file and list common words from the line having the search string

Hi, Need your help for this scripting issue I have. I am not really good at this, so seeking your help. I have a file looking similar to this: Hello, i am human and name=ABCD. How are you? Hello, i am human and name=PQRS. I am good. Hello, i am human and name=ABCD. Good bye. Hello, i... (12 Replies)
Discussion started by: royzlife
12 Replies

9. Shell Programming and Scripting

Read in search strings from text file, search for string in second text file and output to CSV

Hi guys, I have a text file named file1.txt that is formatted like this: 001 , ID , 20000 002 , Name , Brandon 003 , Phone_Number , 616-234-1999 004 , SSNumber , 234-23-234 005 , Model , Toyota 007 , Engine ,V8 008 , GPS , OFF and I have file2.txt formatted like this: ... (2 Replies)
Discussion started by: An0mander
2 Replies

10. UNIX for Dummies Questions & Answers

Search for a string,delete the line and replace with new string in a file

Hi Everyone, I have a requirement in ksh where i have a set of files in a directory. I need to search each and every file if a particular string is present in the file, delete that line and replace that line with another string expression in the same file. I am very new to unix. Kindly help... (10 Replies)
Discussion started by: Pradhikshan
10 Replies
lutab(4)																  lutab(4)

NAME
lutab - list of boot environments SYNOPSIS
/etc/lutab DESCRIPTION
The file /etc/lutab is a list of the boot environments (BEs) configured on a system. There are two entries for each BE. These entries have the following form: BE_id:BE_name:completion_flag:0 BE_id:root_slice:root_device:1 The fields in the lutab entries are described as follows: BE_id A unique, internally generated id for a BE. BE_name The user-assigned name of a BE. completion_flag Indicates whether the BE is complete (C) or incomplete (NC). A complete BE is one that is not involved in any copy or upgrade operation. A BE can be activated or compared only when it is complete. 0 Indicates first of two lines. BE_id As described above. root_slice Designation of the root slice. root_device Device on which the root slice is mounted. 1 Indicates second of two lines. The lutab file must not be edited by hand. Any user modification to this file will result in the incorrect operation of live upgrade. SEE ALSO
lu(1M), luactivate(1M), lucreate(1M), lucurr(1M), lufslist(1M), lustatus(1M), luupgrade(1M), attributes(5), live_upgrade(5) WARNINGS
The lutab file is not a public interface. The format and contents of lutab are subject to change. Use lufslist(1M) and lustatus(1M) to obtain information about BEs. SunOS 5.10 8 Jun 2001 lutab(4)
All times are GMT -4. The time now is 02:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy