Sponsored Content
Top Forums Shell Programming and Scripting Replace line in file with line in another file based on matching string Post 302864071 by nikilbr86 on Tuesday 15th of October 2013 09:35:29 PM
Old 10-15-2013
Replace line in file with line in another file based on matching string

HI

Can any one guide me how to achieve this task. I have 2 files

Code:
env.txt
#Configuration.Properties values
identity_server_url = http://identity.test-hit.com:9783/identity/service/user/register
randon_password_length = 6
attachment_file_path = /pass/temp/attachments/
documentation.services.basePath=http://appserver3.test-d.hit.com:9863/cirrus/service
documentation.services.version=2.0
user.registration.alert.path=emailtemplates/welcomeuser.vm

Code:
configuration.properties
identity_server_url = http://identity.test1-hit.com:9883/identity/service/user/register
randon_password_length = 8
attachment_file_path = /pass/temp/attachments/
documentation.services.basePath=http://appserver2.test1-d.hit.com:9863/cirrus/service
documentation.services.version=1.0
user.registration.alert.path=emailtemplates/welcomeuser.vm

In the above configuration.properties file i need to replace the line "identity_server_url" with env.txt file content. In configuration.properites file before '=' values are constant. After '=' values are changing. So i need to replace the line with matched string before '=' in configuration.properties with env.txt

Thanks
Nikil
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

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. ... (6 Replies)
Discussion started by: kkraja
6 Replies

2. Shell Programming and Scripting

Replace string in a file within a range of line

Hi, I want to replace the srting '; with ABCD'; in a file from line 1 to line 65. Is there any single command to do it without using awk Thanks for quick reply https://www.unix.com/images/misc/progress.gif (3 Replies)
Discussion started by: tosattam
3 Replies

3. Shell Programming and Scripting

replace string in file.1 with line from file.2

Hello all, the title makes this sound simple, and maybe it should be. This is by code: #!/bin/sh cp ch25.txt ch25.fn.tex n=`grep -c '^\' ch25_footnotes.txt > temp` r=`awk -F] '{print $2}' temp` `sed 's/\/\\footnote{$r}/' ch25.fn.tex` done This is what I am trying to... (6 Replies)
Discussion started by: ccox85
6 Replies

4. Shell Programming and Scripting

Retrieve string from each line in a file based on a pattern in Unix

I have a file which contains several lines. Sample content of the file is as below. OK testmessage email<test@123> NOK receivemessage email<123@test> NOK receivemessage email(123@test123) NOK receivemessage email<abc@test> i would like to know by scripting will... (10 Replies)
Discussion started by: ramasar
10 Replies

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

6. Shell Programming and Scripting

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

Hi I am not the best scripter in the world and have run into a issue which you might be able to guide me on... I have two files. File1 : A123, valueA, valueB B234, valueA, valueB C345, valueA, valueB D456, valueA, valueB E567, valueA, valueB F678, valueA, valueB File2: C345,... (5 Replies)
Discussion started by: luckycharm
5 Replies

7. Shell Programming and Scripting

HELP: Shell Script to read a Log file line by line and extract Info based on KEYWORDS matching

I have a LOG file which looks like this Import started at: Mon Jul 23 02:13:01 EDT 2012 Initialization completed in 2.146 seconds. -------------------------------------------------------------------------------- -- Import summary for Import item: PolicyInformation... (8 Replies)
Discussion started by: biztank
8 Replies

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

9. Shell Programming and Scripting

Replace a string with each line from another file repeatedly

I don't know if it's been asked before but seems i gave up seeking. i have 2 files : file1.txt Monday XXXX Tuesday XXXX XXXX Wednesday Thursday XXXX XXXX is in every lines of file1.txt and i want to replace them with each line in file2.txt: home school cinema so output file is: ... (19 Replies)
Discussion started by: perseous
19 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
svcprop(1)																svcprop(1)

NAME
svcprop - retrieve service configuration properties SYNOPSIS
svcprop [-fqtv] [-C | -c | -s snapshot] [-p [name/]name]... [FMRI | pattern]... svcprop -w [-fqtv] [-p [name/]name] {FMRI | pattern} The svcprop utility prints values of properties in the service configuration repository. Properties are selected by -p options and FMRI op- erands. By default, when a single property is selected, its values are printed separated by spaces on a single line. Empty ASCII string values are represented by a pair of double quotes (""). Bourne shell metacharacters (';', '&', '(', ')', '|', '^', '<', '>', newline, space, tab, backslash, '"', single-quote, '`') in ASCII string values are quoted by backslashes (). When multiple properties are selected, a single line is printed for each. Each line comprises a property designator, a property type, and the values (as described above), separated by spaces. By default, if a single FMRI operand has been supplied, the property designator con- sists of the property group name and the property name joined by a slash (/). If multiple FMRI operands are supplied, the designator is the canonical FMRI for the property. A composed property may be selected directly from the entities which match a specified FMRI or from entities which may be used as a source of properties for these matching entities. An example of a composed property is a property which is set on a service, which may be selected when an instance matching an FMRI does not possess the property itself. An un-composed property selection is made against the specified FMRI with no further searching of additional sources of properties other than the entities which match the designated FMRI. Properties are displayed either with or without composition depending on the options which are supplied at invocation. Properties are com- posed by default. A snapshot, which is a point in time representation of the state of a matching entity's properties at a moment in time, always uses compo- sition because snapshots are always composed. Error messages are printed to the standard error stream. Many properties have specific meanings to the Service Management Facility or the service's restarter. The following options are supported: -C Retrieves the current property values, without composition. -c Retrieves the current property values, with composition. -f Designates properties by their FMRIs. Implies option -t. -p [name/]name Prints values of the named property or property group for each of the property groups, instances, or services spec- ified by the operands. -q Quiet. Produces no output. -s snapshot Uses the named snapshot to retrieve the specified property or property group, with composition (since snapshots are always composed). If the given property group is not present in the snapshot, the current property values are exam- ined. -t Uses the multi-property output format. -v Verbose. Prints error messages for nonexistent properties, even if option -q is also used. -w Waits for the selected property group or property to change before printing anything. This option is only valid when a single entity is given. If more than one operand is given, or an operand matches more than one instance, an error message is printed and no action is taken. The -w option always causes svcprop to operate against current property values. The following operand is supported: FMRI With no -p options, FMRI operands can name a service, instance, property group, or property. For services, service instances, and property groups, all contained properties are selected. Instances and services can be abbreviated by specifying the instance name, or the trailing portion of the service name. Properties and property groups must be specified by a full FMRI. For example, given the FMRI: svc:/network/smtp:sendmail The following are valid abbreviations: sendmail :sendmail smtp smtp:sendmail network/smtp The following are invalid abbreviations: mail network network/smt Abbreviated forms of FMRIs are unstable and should not be used in scripts or other permanent tools. Arguments to the -p option can name property groups or properties. In the former case, operands can name services or instances, and all properties in the named property group of the named services or instances are printed. In the latter, operands can name services, instances, or property groups, and the named properties belonging to the operands are printed. By default, all properties are selected from the running snapshot, with composition. If there is no running snapshot, then current properties are selected. The -w and -s options can be used to change the source of properties. When walking properties, that is, no -p options, current nonpersistent property groups are also selected. With -p options, if the property group doesn't exist in the running snapshot, then if the property group is nonpersistent the current property or property group is selected. Example 1: Displaying the Value of a Single Property The following example displays the value of the enabled property in the general property group of instance default of service inetd. example% svcprop -p general/enabled network/inetd:default true Example 2: Displaying All Properties in a Property Group This example displays all properties in the general property group of service ntp. example% svcprop -p general ntp general/entity_stability astring Unstable general/single_instance boolean true Example 3: Verifying the Existance of a Property This example verifies the existence of the general/enabled property for all instances of service identity. example% svcprop -q -p general/enabled identity: example% echo $? 0 Example 4: Waiting for Property Change This example waits for the sendmail instance to change state. example% svcprop -w -p restarter/state sendmail Example 5: Using svcprop in a Script example% cat getval #!/bin/sh svcprop -p $1 $2 | ( read value v2 if [ -n "$v2" ]; then echo "Multiple values!"; exit; fi echo $value ) The following exit values are returned: 0 Successful completion. 1 An error occurred. 2 Invalid command line options were specified. See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ svcs(1), inetd(1M), svcadm(1M), svccfg(1M), svc.startd(1M), service_bundle(4), attributes(5), smf(5), smf_method(5), smf_security(5) 18 Mar 2005 svcprop(1)
All times are GMT -4. The time now is 10:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy