Sponsored Content
Top Forums Shell Programming and Scripting replace (sed?) a single line/string in file with multiple lines (string) from another file?? Post 302515336 by 4dirk1 on Tuesday 19th of April 2011 11:52:01 PM
Old 04-20-2011
Quote:
Originally Posted by rdcwayx
Code:
sed  '/NOVEMBER/r file2.txt' file1.txt |sed '/NOVEMBER/d'

Hi Sir!

I have a similar scenario. I have an xml file which I compiled in unix and i send it out as an attachment which opens with excel. Now there are certain keywords (kw01)in the xml file which I wanted to replace with the contents of txt files having multiple lines.

So i tried your code above with this command:
sed '/kw01/r fatal_alerts.txt' template.xml | sed '/kw01/d' > test.xml

now when I sent out the output file 'test.xml' and open it via excel, the cell where 'kw01' is located is not replaced with the contents of 'fatal_alerts.txt'.

Is there a possible way to do this sir? Need your help badly. Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using sed to replace a string in file with a string in a variable that contains spaces

Hi, i call my shell like: my_shell "my project name" my script: #!/bin/bash -vx projectname=$1 sed s/'PROJECT_NAME ='/'PROJECT_NAME = '$projectname/ <test_config_doxy >temp cp temp test_config_doxy the following error occurres: sed s/'PROJECT_NAME ... (2 Replies)
Discussion started by: vivelafete
2 Replies

2. Shell Programming and Scripting

search string in a file and retrieve 10 lines including string line

Hi Guys, I am trying to write a perl script to search a string "Name" in the file "FILE" and also want to create a new file and push the searched string Name line along with 10 lines following the same. can anyone of you please let me know how to go about it ? (8 Replies)
Discussion started by: sukrish
8 Replies

3. Shell Programming and Scripting

replace a string with contents of a txt file containing multiple lines of strings

Hello everyone, ive been trying to replace a string "kw01" in an xml file with the contents of a txt file having multiple lines. im a unix newbie and all the sed combinations i tried resulted to being garbled. Below is the contents of the txt file: RAISEDATTIME --------------------... (13 Replies)
Discussion started by: 4dirk1
13 Replies

4. Shell Programming and Scripting

SED - Multiple String - Single Line

Would appear to me to be a farily simple question but having search all the threads I can't find the answer .. I just want sed to output the single line in a file that contains two string anywhere on the line.. e.g. currently using this command sed -n -e'/str1/p' -e '/str2/p' < file and... (3 Replies)
Discussion started by: flopster
3 Replies

5. Shell Programming and Scripting

replace (sed?) a string in file with multiple lines (string) from variable

Can someone tell me how I can do this? e.g: a=$(echo -e wert trewt ertert ertert ertert erttert erterte rterter tertertert ert) How do i replace the STRING with $a? I try this: sed -i 's/STRING/'"$a"'/g' filename.ext but this don' t work (2 Replies)
Discussion started by: jforce
2 Replies

6. Shell Programming and Scripting

Grep a string from input file and delete next three lines including the line contains string in xml

Hi, 1_strings file contains $ cat 1_strings /home/$USER/Src /home/Valid /home/Review$ cat myxml <projected value="some string" path="/home/$USER/Src"> <input 1/> <estimate value/> <somestring/> </projected> <few more lines > <projected value="some string" path="/home/$USER/check">... (4 Replies)
Discussion started by: greet_sed
4 Replies

7. Shell Programming and Scripting

sed or awk to replace a value in a certain line from another file containing a string

Hi experts, In my text file I have the following alot of lines like below. input.k is as follows. 2684717 -194.7050476 64.2345581 150.6500092 0 0 2684718 -213.1575623 62.7032242 150.6500092 0 0 *INCLUDE $# filename... (3 Replies)
Discussion started by: hamnsan
3 Replies

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

9. Shell Programming and Scripting

Replace string in XML file with awk/sed with string from another

Sorry for the long/weird title but I'm stuck on a problem I have. I have this XML file: </member> <member> <name>TransactionID</name> <value><string>123456789123456</string></value> </member> <member> <name>Number</name> ... (9 Replies)
Discussion started by: cozzin
9 Replies

10. Shell Programming and Scripting

Replace string of a file with a string of another file for matches using grep,sed,awk

I have a file comp.pkglist which mention package version and release . In 'version change' and 'release change' line there are two versions 'old' and 'new' Version Change: --> Release Change: --> cat comp.pkglist Package list: nss-util-devel-3.28.4-1.el6_9.x86_64 Version Change: 3.28.4 -->... (1 Reply)
Discussion started by: Paras Pandey
1 Replies
asadmin-reconfig(1AS)						   User Commands					     asadmin-reconfig(1AS)

NAME
asadmin-reconfig, reconfig - applies the changes you have made for a server instance SYNOPSIS
reconfig --user admin_user [--password admin_password] [--host localhost] [--port 4848] [--secure|-s] [--passwordfile filename] [--discard- manualchanges=false] [--keepmanualchanges=false] instance_name This command is deprecated. It allows you to apply changes you have made for a server instance. Use the reconfig command after you've used the set command to change server properties. Any changes you make to the configuration files of the server do not take affect until you apply the changes by running the reconfig command. When --discardmanualchanges is set to true, manual changes made to the server.xml file are discarded. When --keepmanualchanges is set to true, manual changes made to the server.xml file take affect. However if both options are false (both options are not specified), an error message is displayed if manual changes and/or changes have been applied using the Adminis- trator Interface. Use this command with discretion since there is no undo, and the changes applied are made directly to your con- fig/backup/server.xmlfile. OPTIONS
--user administrative user associated for the instance. --password administrative password corresponding to the administrative user. --host host name of the machine hosting the administrative instance. --port administrative port number associated with the administrative host. --passwordfile file containing passwords appropriate for the command (e.g., administrative instance). --secure if true, uses SSL/TLS to communicate with the administrative instance. --discardmanualchanges defaults to false. When set to true, discards the changes made manually to the server.xml file. --keepmanualchanges defaults to false. When set to true, allows the manual changes made to the server.xml file to take affect. OPERANDS
instance_name name of the instance.. Example 1: Using reconfig asadmin> reconfig --user admin --passwordfile passwords.txt --host localhost --port 4848 server1 Successfully reconfigured Example 2: Using reconfig with the --discardmanualchanges option asadmin> reconfig --user admin --passwordfile passwords.txt --host localhost --port 4848 --discardmanualchanges server1 Instance restart is required Successfully reconfigured Example 3: Using reconfig with the --keepmanualchanges option asadmin> reconfig --user admin --passwordfile passwords.txt --host localhost --port 4848 --keepmanualchanges server1 Instance restart is required Successfully reconfigured EXIT STATUS
0 command executed successfully 1 error in executing the command asadmin-get(1AS), asadmin-set(1AS), asadmin-list(1AS) J2EE 1.4 SDK March 2004 asadmin-reconfig(1AS)
All times are GMT -4. The time now is 04:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy