Add line in exact place


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Add line in exact place
# 8  
Old 12-11-2013
Would this help you ?

Code:
$ awk '/<INCOND NAME=/{print;s=1;next}s{$0=line_to_be;s=""}1' line_to_be='<QUANTITATIVE ="PRICDRL" QUANT="1" ONFAIL="R" ONOK="R" />' file

Code:
<JOB JOBISN="3" APPLICATION="PRICD" SUB_APPLICATION="DALY" PARENT_FOLDER="PDALY">
<INCOND NAME="PL-PICDDMD82-OK" ODATE="PREV" AND_OR="A" />
<QUANTITATIVE ="PRICDRL" QUANT="1" ONFAIL="R" ONOK="R" />
<OUTCOND NAME="PL-PICDDMD01_SOLOMON_HK_DALY-OK" >
<RULE_BASED_CALENDARS NAME="ALL-DAY-TAG" />
</JOB>
 <JOB JOBISN="4" APPLICATION="PRICD" RENT_FOLDER="PRICDG-SOLOMON-DALY">
<INCOND NAME="PL-PICDDMD81_-OK" ODATE="ODAT" AND_OR="A" />
<QUANTITATIVE ="PRICDRL" QUANT="1" ONFAIL="R" ONOK="R" />
<OUTCOND NAME="PL-PICDDMD82_Y-OK" ODATE="ODAT" SIGN="+" />
<RULE_BASED_CALENDARS NAME="ALL-DAY-TAG" />
</JOB>

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to identify exact text and then add a blank line above it using sed?

I need to identify the exact text of San Antonio Generator Running in the output my script which lands to a text file. Once SED finds the specific text, I need it to insert one line above the matched text. Here is what I have so far that isn't working all that well for me. Any help would be... (7 Replies)
Discussion started by: jbrass
7 Replies

2. Red Hat

Remove new line for a particular place

Hello All, I have a text file which gets uploaded to tables using shells script. However before running that script I need to alter it, like in the below I have to firstly find the word 1234 and remove the new line from end of it. 1234,5678,fasfasasfsadf abc changes to... (11 Replies)
Discussion started by: Sandeep_sandy
11 Replies

3. Shell Programming and Scripting

Copy a field into n line in another place

I have a file contains 100 section (here i show 2 section of that); i want to replace date from 1st & 2nd field of 1st line of each section (1st line of each section is header and the other lines are body) and merg them into one field, then copy it on 7th field of the lines in each section... (17 Replies)
Discussion started by: oreka18
17 Replies

4. Shell Programming and Scripting

script to find backshash and place the content in next line

Hi All, I am new to the forum and scripting...Can someone help me with a code.. My input file will be like $cat first aa a\b bb\ccccc\ddd ee*e\fff\ggg output should be aa a\ b bb\ ccccc\ ddd ee*e\ fff\ ggg I tried with cat first | awk '{ gsub( /\\/, "/\\/" );... (5 Replies)
Discussion started by: madhanmo
5 Replies

5. Shell Programming and Scripting

script for inserting line at specific place in file

I use zentyal for my server admin, which is great but zentyal auto-generates config file on boot and hence overwrites any changes made directly to config files. In order to allow multiple user access to a MS ACCESS database, I need to customise the smb.conf file and add the following line to the... (9 Replies)
Discussion started by: barrydocks
9 Replies

6. Shell Programming and Scripting

Place variables at the beginning of each line

Hello all, I am very new to the shell scripting and I hope someone can help me with this. I have thousands of files with certain format of information and I need to do this for all my files. For each file, grab the numbers in the first and second rows and place them in the position 1 and 2... (8 Replies)
Discussion started by: GoldenFire
8 Replies

7. Shell Programming and Scripting

howto place in one line output from two functions

Hi I would like to place in one line output from two functions. Both functions return text with print cmd. When I place above code in script it will place them in series. e.g. 1 #/bin/ksh 2 3 function1() 4 { 5 print "My name is" 6 ... (3 Replies)
Discussion started by: presul
3 Replies

8. Shell Programming and Scripting

Formatting a text file to get data in exact line by line

I have my data something like this SERIAL FIRSTOCCURRENCE NETPROTOCOL 1947430693 07/01/2009 05:16:40 FR SERIAL FIRSTOCCURRENCE NETPROTOCOL 1947430746 07/01/2009 05:18:05 FR I want the output as follows.... (1 Reply)
Discussion started by: rdhanek
1 Replies

9. Shell Programming and Scripting

Getting the value of a line, that changes place

Hi I am trying to get the value of several results in a file called seq032.diag. The values I am looking for is down under Smooth Tracking nodes and is for g01r01 g02r01 s01t02 etc etc. The problem is that when I try to use look for text and tail etc, it works fine in one result file. In... (1 Reply)
Discussion started by: Navigatorchief
1 Replies

10. Shell Programming and Scripting

How to place the output of two different echo statements on one line

Hello there, I wrote a shell script to modify the code for some of our clients in our client database. Before starting the data modification the program performs a few checks. When a check is being performed, it should be shown on the screen of the user running the program, the result of... (5 Replies)
Discussion started by: JoBa
5 Replies
Login or Register to Ask a Question