Sunday, 25 August 2013

Replace line with multiple trailing patterns

Replace line with multiple trailing patterns

I have 2 files called myfile.txt & responsefile.txt as below.
myfile.txt
user=myname
Was_WAS_AdminId=CN=wsadmin,OU=service,OU=WAS_Secure,OU=tb,ou=dcdc,ou=sysadm,dc=info,dc=prd,dc=dcdc
responsefile.txt
'#'Please fill the user id details.
'#'Here is example user=urname.
user=
'#'Please fill the details.
'#'Here is example Was_WAS_AdminId=CN=wsadmin-xxxx.
Was_WAS_AdminId=
Now, using above two files want to have the following end result after
replacing the matching patterns. The responsefile.txt content should be
intact just the matched pattern should be prefixed with details provided
in myfile.txt or only replace the whole matching line as 1st pattern are
same in both the files and would be more than 100 patterns. SO, please
suggest with a simple solution.
responsefile.txt (new file replaced/substituted with patterns)
'#'Please fill the user id details.
'#'Here is example user=urname.
user=myname
'#'Please fill the details.
'#'Here is example Was_WAS_AdminId=CN=wsadmin-xxxx.
Was_WAS_AdminId=CN=wsadmin,OU=service,OU=WAS_Secure,OU=tb,ou=dcdc,ou=sysadm,dc=info,dc=prd,dc=dcdc
Patterns would be same in both the files for example "user=" or
"Was_WAS_AdminId=" in both the files.
Thanks

No comments:

Post a Comment